Solving ODE in MATLAB help needed

3 views (last 30 days)
Dale
Dale on 22 Oct 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.

Answers (2)

Sachin Ganjare
Sachin Ganjare on 22 Oct 2012
Rfer below link:
Hope you will find the answer!!!

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

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!