What's the alternative of ode45 function ?

조회 수: 4 (최근 30일)
Mallouli Marwa
Mallouli Marwa 2016년 5월 26일
댓글: Sebastian Castro 2016년 5월 26일
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에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by