Effacer les filtres
Effacer les filtres

How to use parsim inside for loop?

2 vues (au cours des 30 derniers jours)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA le 31 Mar 2023
Réponse apportée : Meet le 3 Avr 2023
I have two for loop for simulink simulation. The for loop values are used by the simulink model for simulation. I would like to spped up the simulation by using parsim command. My m.file code look like something this,
ra1=0.6:0.1:1;
rl1=1:0.1:2;
for a=1:length(ra1);
r_a=ra1(a);
for b=1:length(rl1);
r_l=rl1(b);
sim("do something",0.02)
end
end
Here, I would like to change the sim command by parsim. What should I do?

Réponses (2)

Samyuktha
Samyuktha le 3 Avr 2023
Hi Ananta,
It is my understanding that you want to speed up the simulation by using 'parsim' command.
You can replace the 'sim' command with 'parsim' to simulate dynamic system multiple times in parallel or serial. Please refer to the following documantation links for more details on how to use the 'parsim' command:
Hope this helps!

Meet
Meet le 3 Avr 2023
The parsim function runs simulations with different parameters and values based on the Simulink.SimulationInput object. Each Simulink.SimulationInput object specifies one simulation of the model. Therefore, you can create an array of Simulink.SimulationInput objects and then assign the for loop values to the respective parameter of the Simulink.SimulationInput object from the array. Then you can pass this array of Simulink.SimulationInput objects to parsim. This will result in parallel simulations of all the models with different parameters configured for each simulation.
Please refer Run Parallel Simulations - MATLAB & Simulink (mathworks.com) for more details on how parsim works and how to use it.

Catégories

En savoir plus sur Run Multiple Simulations 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