My code below yields the error: Error using alpha
Too many output arguments.
I don't understand why. How can I fix this?
m = size(alpha,1);
if m == 1
alpha = alpha';
end
h = (b-a)/N; %the step size
t(1) = a;
w(:,1) = alpha; %initial conditions
for i = 1:N
k1 = h*f(t(i), w(:,i));
k2 = h*f(t(i)+h/2, w(:,i)+0.5*k1);
k3 = h*f(t(i)+h/2, w(:,i)+0.5*k2);
k4 = h*f(t(i)+h, w(:,i)+k3);
w(:,i+1) = w(:,i) + (k1 + 2*k2 + 2*k3 + k4)/6;
t(i+1) = a + i*h;
end
[t' w']
%function relating the right-hand side of the differential equation
%it has to be changed accordingly to the problem at hand
%in this case, the system of differential equations is:
%dy1/dt = y2
%dy2/dt = -y1 - 2exp(t) + 1
%dy3/dt = -y1 - exp(t) + 1
%change it before proceeding to the command line
function dy = f(t, y)
dy = [y(1) - y(2) + 2; -y(1) + y(2) + 4*t; 0];

답변 (1개)

Star Strider
Star Strider 2019년 5월 16일

0 개 추천

The alpha (link) function sets the face transparency for graphics objects. It has no outputs.
The solution is to rename your variable something else, perhaps ‘alfa’.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

질문:

2019년 5월 15일

답변:

2019년 5월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by