What's the alternative of ode45 function ?
8 views (last 30 days)
Show older comments
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]);
0 Comments
Answers (1)
Sebastian Castro
on 26 May 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 Comments
Sebastian Castro
on 26 May 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
See Also
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!