Changing the Sample Rate in Simulink while simulation is running

2 views (last 30 days)
Dear Community members,
I am simulating the Sound of an engine and I want to be able to change the Sample Rate of my Audio file in Simulink to simulate an accelerating engine (rising RPM). I am using as shown in the picture a simple 'from Workspace block' that reads a vector containing the amplitudes of my Sound data and transmits it to 'to Audio device' block.
The Problem is that I can't Change the Sample Rate once the Simulation is running.
I don't get this Problem in Matlab as I can use a Loop and Change the Sample Rate in every Iteration:
for k=0:50,
sound(h,60000+k*1000);
end
However I was not able to incorporate this code in Simulink. I hope that the question is clear and that you are able to help me. Thanks
Oussama

Answers (1)

Erik Voigt
Erik Voigt on 6 Sep 2017
Hi I look into the same problem. There is a more or less straight forward solution using triggered subsystem. As it seems this is the only standard-way in Simulink to change rate autonomously during simulation. But if you have complex systems as we have in Drives, you are then forced to group all rates together in the same system, to keep the execution-order easy to understand (so 1 subsystem per rate). However we would prefer a functional grouping and the rate as a secondary deployment-specific thing. Building a complete scheduling system inside simulink could also be a soluition (either in stateflow or in Matlab-block), where you trigger each "block" individually and control the execution-queue explicitly yourself. But this already sound too complex to maintain in the long run, so.... I am surprised that nobody commented or answered you post here...does not sound good for myself and my problem ... :-) kr Erik

Categories

Find more on Audio I/O and Waveform Generation 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!