Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Can someone explain why I keep getting an error in MatLab on the bolded line. Its in the function y-Y(i)+h*(y-y.^2 + 1.14*cos(exp(t/2)) . I have...

Can someone explain why I keep getting an error in MatLab on the bolded line. Its in the function y-Y(i)+h*(y-y.^2 + 1.14*cos(exp(t/2)) . I have tried everything. Thank you :)

%Eulers Improved

%y'=y-y^2+1.14*cos(exp(1)^(t/2)

y0=-.5;

t0=0;

tEnd=20;

h=1/32;

N=(tEnd-t0)/h;

%%Initialize Solutions

T= [0:h:tEnd]';

Y=zeros(N+1,1);

Y(1)=y0;

%%Solve using Eulers Improved Method

for i=1:N

  t=T(i)+h;

  y= f..(@(y)  y-Y(i)+h*(y-y.^2 + 1.14*cos(exp(t/2)), Y(i);

  T(i+1) = t;

  Y(i+1)=y;

end

%%Plot 

plot(T,Y);

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question