From: Martin on
Hi,
I'm looking for a way to solve a system of differential equations. In the last of the four equations on the right side is a (known) function u (t). The corresponding values to u are available as a vector. The number of elements in that vector is the same as in the vector tspan = [t0,t1,...,tf]. My function file looks like that:
%
function dy = quarter_car_ode(t,y)
%
dy = zeros(4,1);
dy(1) = y(2);
dy(2) = (k_M/M)*(y(4)-y(2))+(c_M/M)*(y(3)-y(1));
dy(3) = y(4);
dy(4) = (k_M/m)*(y(2)-y(4))+(c_M/m)*(y(1)-y(3))+(c_m/m)*(u-y(3));
%
How can I tell the solver to take an element u(i) at a time t(i)?

Thanks for your help,
martin
From: Steven Lord on

"Martin " <martin3421(a)googlemail.com> wrote in message
news:hu128r$8fq$1(a)fred.mathworks.com...
> Hi,
> I'm looking for a way to solve a system of differential equations. In the
> last of the four equations on the right side is a (known) function u (t).
> The corresponding values to u are available as a vector. The number of
> elements in that vector is the same as in the vector tspan =
> [t0,t1,...,tf]. My function file looks like that:
> %
> function dy = quarter_car_ode(t,y)
> %
> dy = zeros(4,1); dy(1) = y(2);
> dy(2) = (k_M/M)*(y(4)-y(2))+(c_M/M)*(y(3)-y(1));
> dy(3) = y(4);
> dy(4) = (k_M/m)*(y(2)-y(4))+(c_M/m)*(y(1)-y(3))+(c_m/m)*(u-y(3));
> %
> How can I tell the solver to take an element u(i) at a time t(i)?

Use INTERP1.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Martin on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hu1tbe$q1v$1(a)fred.mathworks.com>...
>
> "Martin " <martin3421(a)googlemail.com> wrote in message
> news:hu128r$8fq$1(a)fred.mathworks.com...
> > Hi,
> > I'm looking for a way to solve a system of differential equations. In the
> > last of the four equations on the right side is a (known) function u (t).
> > The corresponding values to u are available as a vector. The number of
> > elements in that vector is the same as in the vector tspan =
> > [t0,t1,...,tf]. My function file looks like that:
> > %
> > function dy = quarter_car_ode(t,y)
> > %
> > dy = zeros(4,1); dy(1) = y(2);
> > dy(2) = (k_M/M)*(y(4)-y(2))+(c_M/M)*(y(3)-y(1));
> > dy(3) = y(4);
> > dy(4) = (k_M/m)*(y(2)-y(4))+(c_M/m)*(y(1)-y(3))+(c_m/m)*(u-y(3));
> > %
> > How can I tell the solver to take an element u(i) at a time t(i)?
>
> Use INTERP1.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>
THANK YOU!