HOW TO WRITE THE FUNCTION FOR ODE45
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
wan rabiatul adawiyyah
le 8 Juil 2020
Modifié(e) : darova
le 8 Juil 2020
Hi. I am still new in Matlab and i don't know how to write this function for this equation. I know i must use ode45 but i don't know how to write that function coding(for eqn 21 and 22)(I attached with the journal that i referred):

I try to write it but it is have some error, this is how i write:
function dvdt=velocityspinsolver(times,velocities)
dvdt=-g-(Kv/m)*sqrt(v^2+v^2)-Dwv/m;
dvdt=(-Kv/m)*sqrt(v^2+v^2)+Kwv/m; %equation (21)
g=32.174;
K=0.00832;
m=0.59375;
D=0.001452;
w=51;
And this is the error:
Unrecognized function or variable 'g'.
Error in velocityspinsolver (line 2)
dvdt=-g-(Kv/m)*sqrt(v^2+v^2)-Dwv/m;
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in dua (line 44)
[time,velocities] = ode45('velocityspinsolver',0:.005:5, V0);
0 commentaires
Réponse acceptée
madhan ravi
le 8 Juil 2020
ode45(@velocityspinsolver, [0,10],[1,1])
function dvdt=velocityspinsolver(t,y)
y = zeros(2,1);
vx = y(1);
vy = y(2);
g=32.174;
K=0.00832;
m=0.59375;
D=0.001452;
w=51;
dvdt = [-g-(K*vx/m)*sqrt(vx^2+vy^2)-D*w*vy/m;
(-K*vy/m)*sqrt(vx^2+vy^2)+K*w*vx/m]; %equation (21)
end
7 commentaires
madhan ravi
le 8 Juil 2020
How’s this related to the question you originally asked?? First you asked about ode45() and now a loop?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

