What's the alternative of ode45 function ?

10 vues (au cours des 30 derniers jours)
Mallouli Marwa
Mallouli Marwa le 26 Mai 2016
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]);

Réponses (1)

Sebastian Castro
Sebastian Castro le 26 Mai 2016
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 commentaires
Mallouli Marwa
Mallouli Marwa le 26 Mai 2016
No i haven't simulink. Can i use lsim as a relative of ode45 and how ? Please help me
Sebastian Castro
Sebastian Castro le 26 Mai 2016
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

Connectez-vous pour commenter.

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by