EULER'S METHOD FOR 2ND ODE
13 ビュー (過去 30 日間)
古いコメントを表示
I can't figure out why I am not getting a numerical solution and consequently a graph for the my code:
t0 = 0;
t = 5;
h = 0.1;
N = (t-t0)/h;
T = [t0:h:t]';
Y = zeros(N+1,1);
Y(1) = 3;
%Start of Euler Method
syms Y(t)
E = diff(Y,2) + .1*diff(Y) + .3*Y == .02*Y^3;
V = odeToVectorField(E)
Y = sym(zeros(size(t)));
for i = 1:N
P = V(2);
Y(i+1) = Y(i) + h*P;
S = Y(i+1)
end
figure(2)
plot(T,Y,'-o')
this is the error im getting;
Error using plot
Data must be numeric, datetime, duration or an array convertible
to double.
Error in Euler (line 21)
plot(T,Y,'-o')
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!