Too many output arguments
Show older comments
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];
Answers (1)
Star Strider
on 16 May 2019
0 votes
The solution is to rename your variable something else, perhaps ‘alfa’.
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!