EULER'S METHOD FOR 2ND ODE

13 ビュー (過去 30 日間)
Andres Cardenas
Andres Cardenas 2019 年 12 月 9 日
編集済み: Andres Cardenas 2019 年 12 月 9 日
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 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by