How to use set_param(BlockX, 'SampleTime') during runtime of Simulink?
Show older comments
Dear Community,
i know the topic of how to use set_param() to change params of chosen Simulink Blocks is well discussed, but I couldn't get an answer to this:
As the pictures show, I got a sin(x) signal, doing 3 periods wth a certain frequency before i got another iteration with higher frequency and so on. This goes from 0.1mHz to 1kHz and I want to have 600 samples per period. Meaning that I want to change the sample time of the "Signal Editor" Block everytime I go to a higher frequency. Therefore I want the sample time to be 1/(SamplesPerPeriod*CurrentFrequency).
The counter and the matlab-fcn only get relevant when the frequency jumps to the higher value and tries to update the sample time by:
set_param('SineTest/Signal Editor','SampleTime',SampleTime_new);
But it says that it 'cannot change parameter 'Sample Time' of Signal Editor while simulation is running' How do i solve this? Is there a way that i can change it during runtime or tell Simulink to pause, change it and resume?
Thanks for your help in advance :)
Best wishes
Accepted Answer
More Answers (0)
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!