Solving ODE in MATLAB help needed

3 Ansichten (letzte 30 Tage)
Dale
Dale am 22 Okt. 2012
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.

Antworten (2)

Sachin Ganjare
Sachin Ganjare am 22 Okt. 2012
Rfer below link:
Hope you will find the answer!!!

Walter Roberson
Walter Roberson am 22 Okt. 2012
-(k/m)Vx does not indicate multiplication in MATLAB. -(k/m) .* Vx
Likewise for other multiplication operations in your code.

Kategorien

Mehr zu Programming 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!

Translated by