I am trying to solve the implicit euler method u sing matlab. I get this error. If the input expression contains a symbolic variable, use the VPA function instead.
7 views (last 30 days)
Show older comments
n=input('n='); tf=9; t0=0; h=(tf-t0)/n; t=linspace(t0,tf,n+1); y=zeros(4,n); y0 = [0.5;0;0;50]; y(:,1)=y0; for i=1:n y0(:,i+1)=y(:,i); while (norm (y(:,i+1)-y0(:,i+1)) > 0.0001) y(:,i+1)=y0(:,i+1)+((eye(length(y0)))-(h*(DG(y0(:,i+1)))))\((-h*G(y0(:,i+1)))-(y(:,i))); end
y(:,i+1)=y(:,i);
t(i+1)=t(i)+h;
end
plot(t,y)
Here G is the function and DG is the jacobian of the function in separate files.
2 Comments
Christopher Creutzig
on 31 Mar 2014
Please format your code so it is readable (select the code and click the “Code” button, observer the Preview window) and include everything needed to run the code. If possible at all, after reducing the code to a minimal example. E.g., your code contains G and DG without any definition. Also explain what you tried and at what point MATLAB behaves differently from what you expected and why you expected it that way.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!