Home > Software design >  Random signls and clocktime in Simulink
Random signls and clocktime in Simulink

Time:08-12

I have a problem in understanding a simple matlab property. If you have this simple model with the clock, a matlab function and a scope. Why does the fuction is just run every 0.2 seconds in the simulation time? Same when you use 100 as Stop time. Then the function will be run every 2 seconds. In between the random values generated by the funtion, Simulink connects the values linearzed. Next question is why is simulink generating alwys the same "random"signal? I want to implement a random noise signal in a bigger model, but i think i did not understand how it works.

function y = fcn(u)
y  =rand;
end

enter image description here

CodePudding user response:

Change the solver type to and set the timestep to whichever value you want in order to obtain the results at the desired time intervals.

Regarding the result of the rand function, you can initiate it each time with a different seed (based on the current time) by calling the rng function before rand with the mode :

function y = fcn(u)
rng('shuffle');
y  =rand;
end
  • Related