how to use two while and for loops?

hi to all:
i have two condition in my problem in matlab.
(1) matlab should run the first statement when x<1 .
(2) when x reaches to x>1 or x=1 the matlab should run the second statement.
thanks from all of you

Answers (1)

if x < 1
statement1
elseif x >= 1
statement2
end

6 Comments

Respected sir thanks from your reply but x is not single value it is matrix.
Let me explain it to you I have four rows which I called it x if one row reaches to one or greater than one than it should go to row two and follow the same procedure till last row. Thanks
[m,n] = size(x) ;
for i = 1:m
for j = 1:n
if x(i,j) < 1
statement1
elseif x(i,j) >= 1
statement2
end
end
end
thanks you so much respected sir
this is that part of my programming which i have proble.
while m(i)<1
i=1:n-1
itn=itn+1
Rhn(1:n,i) = ((pi*rh(1:n,i).^4)/8*nuD*L).*(m(i)+(1-m(i))*M);
qhn(1:n,i)=qh(1:n,i).*Rh(1:n,i)./Rhn(1:n,i);
Vh(1:n,i) = (qhn(1:n,i))./Ah(1:n,i)
if m(i)<=0.5
delXmax = 0.1
else
delXmax = 0.07
end
deltat=min(min(delXmax./Vh))
m(i)= m(i)+Vh(1:n,i)*deltat;
end
end
i want that m should strat from 0 and run in first row or column when it reaches to 1>= 1 , than it should move to second row or column and foloow same initail condition (m>=1). once again thank you so much
i is the number of rows respected sir first i wan to do it for rows than for columns .
where i=1
it should follow the rule i+1 when m>=1.
thanks
as you know in my programming the loop will stop when m reaches to 1 or greather 1, but i want it should go for i=2 and than i=3 and so on

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2017a

Community Treasure Hunt

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

Start Hunting!