필터 지우기
필터 지우기

Name Storage with Repeat loops

조회 수: 2 (최근 30일)
TS
TS 2015년 4월 29일
댓글: TS 2015년 4월 29일
f=input('Enter First Name:')
l=input('Enter Last Name:')
for [f,l]
repeat
strvcat(f,l)
until f=Jed
end
I need help with this code, what I'm tying to do is store names in a loop until the name Jed is typed in. I thought this code would do the trick, but I am unsuccessful.
  댓글 수: 2
the cyclist
the cyclist 2015년 4월 29일
편집: the cyclist 2015년 4월 29일
Are you using MuPAD? There is no "repeat ... until" structure within MATLAB.
TS
TS 2015년 4월 29일
No, in fact, I found this from a source online.

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

채택된 답변

James Tursa
James Tursa 2015년 4월 29일
Use a while loop if you want to loop repeatedly until some condition is met. E.g.,
while( true )
f=input('Enter First Name:')
l=input('Enter Last Name:')
% Insert processing code here
if( strcmpi(f,'Jed') )
break;
end
end
  댓글 수: 1
TS
TS 2015년 4월 29일
Thank you! This helps so much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by