What's the alternative of ode45 function ?

8 次查看(过去 30 天)
Hi, i have done this function to resolve a second order differential equation but i want to fix the time as a constant equal to 10 by changing the ode45 by another function:
function xdot = equacte(t,x,rload)
% Function file for mass with spring.
% Position is first variable, velocity is second variable,load is the third variable
freq=100;
w=2*pi*freq;
m=0.0112;
k=279.9919 ;
teta =-7.3333e+03;
cp= 1.8492*10^-7;
A = [0,1,0;-k/m,0,-teta/m;(-teta/rload),0,-1/(rload*cp)];
B = [0;1/m;0];
f =sin(w*t);
xdot = A*x+B*f;
end
Then in principle program:
rload=5000;
[t,x]=ode45(@(t,x) equacte(t,x,rload),[0:0.000001:5],[0,0,0]);

回答(1 个)

Sebastian Castro
Sebastian Castro 2016-5-26
How about this:
Keep in mind that the variable-step ode45 may be taking much smaller time steps to keep the integration error down. With a fixed-step solver, you have no guarantees of meeting error tolerances and your sample time will have to be carefully chosen.
- Sebastian
  4 个评论
Mallouli Marwa
Mallouli Marwa 2016-5-26
No i haven't simulink. Can i use lsim as a relative of ode45 and how ? Please help me
Sebastian Castro
Sebastian Castro 2016-5-26
That might work. You could get away with discretizing the system to your sample rate of 10 using c2d and then passing it in to lsim. According to the documentation,
Discrete-time systems are simulated with ltitr (state space) or filter (transfer function and zero-pole-gain).
- Sebastian

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by