EULER'S METHOD FOR 2ND ODE

11 visualizzazioni (ultimi 30 giorni)
Andres Cardenas
Andres Cardenas il 9 Dic 2019
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')

Risposte (0)

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by