I want to stop my simulink code after 10 seconds of running

조회 수: 22 (최근 30일)
Rahul Shekar
Rahul Shekar 2022년 6월 30일
댓글: jibrahim 2022년 7월 1일
I am using simulink audio tool box to record an audio.
I am starting this simulink code using my matlab code.(sim("*simulink file name*")).
But i want this simulink file to run for 15 seconds so the .wav file output from the simulink code can be read by the matlab code.

답변 (2개)

Jon
Jon 2022년 6월 30일
So I'm assuming you mean that you want the Simulink model to run for 15 seconds of real time. Otherwise if you just want it to run for 15 seconds of simulated elapsed time you could just set you stop time to 15 seconds.
To make it run for 15 seconds of real time you can use the Simulation Pacing Option. To get to this setting click on the drop down below the Run button. There you can check the box for "Enable pacing to slow down simulation, and set the slider for Simulation timer per wall clock second to 1. With those settings, if you set the stop time of the simulation to 15 seconds, the real elapsed time will also be 15 seconds.
  댓글 수: 4
Jon
Jon 2022년 6월 30일
Finally, I should have noticed earlier that you are using a special toolbox "Audio Toolbox"
I am not familiar with this toolbox, but it is quite possible it has some built in settings to allow you to capture data for a specified amount of real time. In this case I would just use the built in functionality
Walter Roberson
Walter Roberson 2022년 6월 30일
audiorecorder() is useful for capturing a specific amount of audio data.

댓글을 달려면 로그인하십시오.


jibrahim
jibrahim 2022년 7월 1일
This should work:
sim(modelname, 15)
  댓글 수: 2
Jon
Jon 2022년 7월 1일
Yes, you can set the stop time programmatically as you show. I think the OP wants the model to run for 15 seconds of realtime, that is what I explained in my answer above.
jibrahim
jibrahim 2022년 7월 1일
If the audio IO blocks are used (e,g audio Device Reader, Writer...), then the model will run in realtime with no required changes from the user. The IO blocks will take care of blocking execution.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by