Is there a way to pause matlab script while smvideowrite records a multi body animation?

3 ビュー (過去 30 日間)
Christopher Bitikofer
Christopher Bitikofer 2018 年 3 月 2 日
編集済み: Jason Nicholson 2024 年 12 月 20 日
Is there a way to pause matlab script while smvideowrite records a multibody animation? I have a Simulink model which I am sweeping through many data-sets so creating the animations programmatically in a loop is the only realistic way of processing the set; however rerunning the Simulink model will clear the mechanics explorer smvideowrite needs open to complete an animation. Currently I'm using pause statements to try to give the writer enough time to finish an animation but haven't been sucessjust ends up getting behind and failing anyway eventually. If there is some way to pause the script until video writer closed I would love to know about it!

回答 (1 件)

Jason Nicholson
Jason Nicholson 2024 年 12 月 20 日
編集済み: Jason Nicholson 2024 年 12 月 20 日
You can work around this issue.
% simulate the model
sim("myModel");
% start writing the video
tic;
smwritevideo("myModel","myVideo.avi");
toc;
% wait for the video to complete writing by checking if you can read it
whileFlag = true;
tic
while whileFlag
try
a = VideoReader("myVideo.avi");
whileFlag = false;
catch e
counter = counter + 1;
pause(1)
end
end
toc;

カテゴリ

Help Center および File ExchangeSimulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by