Random signls and clocktime in Simulink
조회 수: 3 (최근 30일)
이전 댓글 표시
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1093040/image.png)
댓글 수: 1
Atsushi Ueno
2022년 8월 10일
이동: Atsushi Ueno
2022년 8월 17일
>Why does the fuction is just run every 0.2 seconds in the simulation time?
You must be using a Variable-step solver. It changes the step size during the simulation, reducing the step size to increase accuracy when model states are changing rapidly and increasing the step size to avoid taking unnecessary steps when model states are changing slowly. You can set expected step size as "Fixed-step size" below.
>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.
When you set the same seed value like zero as default, the rand function always return the same set of value. You need changing the seed value of the rand function.
Example: Each time you run the model, you will get different seed values depending on the time of day.
rng(sum(clock))
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!