Matlab Ode45. Trouble with Function Handle @ When Setting up Equations for Ode45

Having trouble in using a random white noise in ode45 function handle input.

I am using ode45 function to solve a 2 degree of freedom mechanical system (spring/mass/viscous damper). I have the differential equations, where s(1) s(3) are displacements of the two masses, s(2) and 2(4) are the velocity of the two masses. f(t) is the exciting force of the system. K1 k2 are the stiffness (constant), m1 m2 the masses (constant), c damping coefficient (constant)

sdot = @(t,s) ...
    [s(2);
    (-k1*s(1)-k2*(s(1)-s(3))-c*(s(2)-s(4))+f(t))/m1;
    s(4);
    (k2*(s(1)-s(3))+c*(s(2)-s(4)))/m2];

I want the force f(t) to be a random white noise that I can scale (scaling factor f0), for example:

rng(3);
f0=100;
f@(time) f0*randn;

The way I am calling the function ode45 is:

[time,result]=ode45(sdot,tspan,IC);

The problem is, when I increase f0 the amount of steps in the calculation increases dramatically (f0=1 gives 46,000 steps ; f0=100 gives 4,342,705 steps). Which I do not want, I just want the magnitude of the random noise to increase.

Any advice on how to set up a better random force to the system of equations mentioned?

1
Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article