Solving ODE in MATLAB help needed
2 次查看(过去 30 天)
显示 更早的评论
Question: Solve numerically up to t=1
a) x= 20, values for y and z
b) x= 9, values for y and z
Equations:
{dVx/dt= -(k/m)Vx-cVy;}
[dVy/dt= -(k/m)Vy-cVx:]
[dVz/dt= -(k/m)Vz-g:]
I tried the first equation:
function x = test_dVxdt (t,x)
global k m c Vx Vy
x = -(k/m)Vx - cVy;
return
In the command window
k= 0.17;
>> m= 0.43;
>> c= 0.24
c =
0.2400
>> Vx= 26.76;
>> Vy= -2.813;
>> tspan= [0:0.1:1];
>>
>> x= 20;
>> [t, x] = ode45(@test_dVxdt, tspan, x)
But I am getting a lot of errors,
Error using feval
Error: File: test_dVxdt.m Line: 4 Column: 11
Unexpected MATLAB expression.
Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Am I going about the question correctly? Any help would be appreciated.
0 个评论
回答(2 个)
Walter Roberson
2012-10-22
-(k/m)Vx does not indicate multiplication in MATLAB. -(k/m) .* Vx
Likewise for other multiplication operations in your code.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!