MATLAB: Can I not plot two simple vectors? Matlab keeps returning “too many input arguments” Help!

argumentserrorinputplotplotting

function [t,y] = Euler(h)
% Simple Euler integration method for the Ordinary Differential Equation
%

% dy/dt = f(t,y), initial condition: y(1) [see below]
%
% with stepsize h. t and y are vector-valued outputs for the solution
% y at time t.
Tmax = 1; % final time
f = @(t,y) -3.*y;
y(1) = 1;
t = [0:h:Tmax]; % h is the stepsize: make sure Tmax is divisible by h!
for i=1:length(t)-1
y(i+1) = y(i) + h*f(t(i),y(i));
end
figure
plot(t,y)
end

Best Answer

I saved your code to a file named Euler.m, and then called it with
Euler(0.1)
and it ran just fine. Is that what you are doing?
What is the output of
which Euler
?
Maybe you defined Euler as both a variable and a function?