I have a script where the user should input to numbers and after that I want to make a loop between these numbers. However if I input a 2 digit number it doesn't work for some reason.
Here is my code:
ModeNumber=input('First mode ','s');
ModeLast=input('Last mode ','s');
for mLoop = ModeNumber:ModeLast
I tried making the input a number by removing the 's' and I also tried using str2num in the mLoop, but this doesn't work as well.
Thanks

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 14일

0 개 추천

ModeNumber=input('First mode ');
ModeLast=input('Last mode ');
for mLoop = ModeNumber:ModeLast
A(mLoop)=cos(mLoop)
end
What is not working in this example?

댓글 수: 3

Dimitar
Dimitar 2013년 8월 14일
It is working, but I get an error on mine: "Warning: Colon operands must be real scalars." any idea where this may come from?
Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 14일
Ok, but how can we guess what is in your code ?
Dimitar
Dimitar 2013년 8월 14일
I fixed it. The problem was that if my mode numbers are strings mloop would also be a string
thank you

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by