Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

while loop/breaking a loop

1 visualización (últimos 30 días)
Rengin
Rengin el 22 de Abr. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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!

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by