Effacer les filtres
Effacer les filtres

Running n instances of the same function simultaneously

3 vues (au cours des 30 derniers jours)
Eythan Haimov
Eythan Haimov le 3 Sep 2022
Hi,
I have a GUI written in appdesigner with a function that takes a data matrix and uses it to display a "frame", running this in a while loop results in a video being played. This is the code for it:
function PlayButtonPushed(app, event)
% Start conditions
Frame = app.CurrentFrame.Value;
PauseTime = app.TimeBetweenFrames.Value;
NumOfFrames(1) = app.Arena(1).File.NumberOfFrames;
% Main loop
while Frame <= NumOfFrames
DisplayFrame(app, Frame);
drawnow % Update GUI after displaying frame
pause(PauseTime);
% Stop condition
if strcmp(app.StopValue, 'On')
app.StopValue='Off';
break
end
% Update conditions for the next frame
FrameInterval = app.FrameInterval.Value;
Frame = app.CurrentFrame.Value+FrameInterval;
app.CurrentFrame.Value = Frame;
PauseTime = app.TimeBetweenFrames.Value;
app.TimeBetweenFrames.Value = PauseTime;
end
end
So as you can see, app.Arenas is an array and currently it only display the first arena, I would like to expand on it, being able to view two or four(or n, for a generallity) arenas at the same time. I could just loop the "DisplayFrame" function for n but I may want to take in to account the fact that maybe different arenas have a different "total frames" for them, and also, looping it will be a lot slower.
Is there anyway to have this function run multiple times, simultaneously?
Thanks!

Réponses (1)

Matt J
Matt J le 3 Sep 2022
You can use parfeval, assuming you have the Parallel Computing Toolbox.

Catégories

En savoir plus sur Manage Products dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by