How to write this in the for loop?
3 次查看(过去 30 天)
显示 更早的评论
Dear All,
I have a for loop and I want to read n for n=1:100 and n=200:300,
for n= 1:100 and 200:300;
How to write it in the for loop?
回答(2 个)
Abderrahim. B
2022-8-28
Try this --
for n = [1:100 200:300]
continue % adding this just to demonstrate
end
0 个评论
Swaroopa
2022-8-28
Hi Ara,
You can use for loop and if condition to read n for numbers 1 to 100 and 200 to 300 in the following way
for i=1:500
if (i>=1 & i<=100) | (i>=200 & i<=300)
input("Enter an number : ")
end
end
Hope it helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!