why i am getting too many input arguments
Show older comments
function EulersMethod
%Eulers method
%y' = -2x^3+12x^2-20x+8.5 from x = [0 4] y(1) = 1 and h=0.5
a = 0; %Interval we are using, from a to b.
b = 0.5;
y(1) = 1; %Initial value of y, i.e. y = 1 for x= 0.
N = 9; %Number of steps we will use
t(1) = a; %inital time we will start at
h = (b - a) / N; %Step size
f= @(x) (-0.5*x.^4)+(4*x.^3)-(10*x.^2)+(8.5*x)+1; %model we are using
for i=1:N
y(i+1) = y(i) + h*f(y(i), t(i)); %Implementation of Eulers method
t(i+1) = a + i*h;
end
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!