Thread Subject:
i have problem with o

Subject: i have problem with o

From: jdd Big

Date: 5 May, 2012 15:16:08

Message: 1 of 1

Hi every body ,

I want to solve Differential equation 2nd order by ode45

my function is

function dx=model(t,x)
%initial value
M=1;
r=1.27;
Km=4.9;
Kb=0.0507;
R=0.3;
b=0.5;
T=1.0;
Per=T;
P=0.0;
P1=0.5;
P2=1;
%to calculate the voltage
if ((t>=P) && (t<P1))
    V=5;
end
if ((t>=P1) && (t<P2))
    V=-5;
end
if (t==Per)
    P=P+T;
    P1=P1+T;
    P2=P2+T;
    Per=Per+T;
end
%to calculate the parameter
F1=b+((2*pi/r)^2)*((Km*Kb)/R);
F=(2*pi/r)*(Km/R)*V;
%our differential equation
dx1=x(1);
dx2=(F/M)*V-F1/M*x(2);
dx=[dx1;dx2];

return

and main program is

clear all
clc
%initial valeu
x1=0.0;
x2=0.0;
T=0;
h=0.004;
while T<100
x0=[x1 x2];
[t,x]=ode23(@model,[0,h],x0);
n=length(x);
x0=x(n,:);
x1=x0(1);
x2=x0(2);
T=T+h;
x0=[x1 x2];
end

but i found error ''??? Error using ==> odearguments at 113
MODEL must return a column vector.",and I do not understand where is the fault

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us