Solving ODE in MATLAB help needed

조회 수: 3 (최근 30일)
Dale
Dale 2012년 10월 22일
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.

답변 (2개)

Sachin Ganjare
Sachin Ganjare 2012년 10월 22일
Rfer below link:
Hope you will find the answer!!!

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by