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
回答(1 个)
KSSV
2021-3-7
if x < 1
statement1
elseif x >= 1
statement2
end
6 个评论
Engineer Batoor khan mummand
2021-3-7
Engineer Batoor khan mummand
2021-3-7
编辑:Engineer Batoor khan mummand
2021-3-7
KSSV
2021-3-7
[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
Engineer Batoor khan mummand
2021-3-7
Engineer Batoor khan mummand
2021-3-7
Engineer Batoor khan mummand
2021-3-7
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!