Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

while loop/breaking a loop

조회 수: 1 (최근 30일)
Rengin
Rengin 2015년 4월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
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!

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by