HOW TO WRITE THE FUNCTION FOR ODE45
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
wan rabiatul adawiyyah
am 8 Jul. 2020
Bearbeitet: darova
am 8 Jul. 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 Kommentare
Akzeptierte Antwort
madhan ravi
am 8 Jul. 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 Kommentare
madhan ravi
am 8 Jul. 2020
How’s this related to the question you originally asked?? First you asked about ode45() and now a loop?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

