HOW TO WRITE THE FUNCTION FOR ODE45
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
madhan ravi
2020년 7월 8일
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
madhan ravi
2020년 7월 8일
How’s this related to the question you originally asked?? First you asked about ode45() and now a loop?
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!