Effacer les filtres
Effacer les filtres

how can i assign multiple output from a function using parfor?

1 vue (au cours des 30 derniers jours)
Vanita Pawar
Vanita Pawar le 25 Mai 2015
Modifié(e) : Matt J le 26 Mai 2015
My function is generating 3-dimentional 5 variable. for montecarlo run i have to generate that 100 times. how can i use parfor that ?or do i have to use some other command?

Réponses (2)

Walter Roberson
Walter Roberson le 25 Mai 2015
You should be able to use parfor for it.
maxtrial = 100;
results = cell(maxtrial,1);
parfor trialnum = 1 : maxtrial
generate first variable
generate second variable
generate third variable
generate fourth variable
generate fifth variable
calculate outputs with those variables
results{K} = outputs;
end
If the result is a single numeric value then use a numeric array instead of a cell array.

Matt J
Matt J le 26 Mai 2015
Modifié(e) : Matt J le 26 Mai 2015
Something like this should work,
outputs=cell(N,5);
parfor i=1:N
[outputs{i,1:5}]=yourFunctionCall;
end

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by