How to write this in the for loop?

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

rumin diao
rumin diao 2022년 8월 28일
use two loops 1:100 and 200:300 seperately?
Ara
Ara 2022년 8월 28일
I want to read 1:50 and also 100:200 in one file. The output contain these two groups.

댓글을 달려면 로그인하십시오.

답변 (2개)

Abderrahim. B
Abderrahim. B 2022년 8월 28일

0 개 추천

Try this --
for n = [1:100 200:300]
continue % adding this just to demonstrate
end
Swaroopa
Swaroopa 2022년 8월 28일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

Ara
2022년 8월 28일

댓글:

Ara
2022년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by