Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

while loop/breaking a loop

1 vue (au cours des 30 derniers jours)
Rengin
Rengin le 22 Avr 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
Dear Users,
clear all
clc
nparticle=15;
nclass=3;
maxlimit=10;
minlimit=50;
value=zeros(nparticle,nclass);
for i=1:nparticle
for j=1:nclass
value(i,j)= round(minlimit + (maxlimit-minlimit).* rand (1));
end
end
% In that part, I want to check the cells in a row one by one and if one
% cell doesn't meet the requirement what I put,I want to go back the
% beginning of the main loop and go on generating random values.
% My condition: if value(i,j)>25--> assign new random values for ith
% particle!
% Let's say value(4,1)=12 value(4,2)=28 value(4,3)=10
% 4-->4th particle
% 2-->2nd class
% It means my 4th particle doesn't meet the requirement (>25) independent
% from nclass/column/j.
% In that case, I want to assign 4th particle with new random values till I
% meet the requirements for 4th particle. I want to continue the process
% till I fulfill all rows of value(nparticle,nclass) matrix.
How can I solve that problem? Many thanks!

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by