Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

while loop/breaking a loop

1 Ansicht (letzte 30 Tage)
Rengin
Rengin am 22 Apr. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 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!

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by