필터 지우기
필터 지우기

Name Storing in a While Loop

조회 수: 1 (최근 30일)
TS
TS 2015년 4월 29일
답변: James Tursa 2015년 4월 29일
while (true)
f=input('Enter First Name:','s');
l=input('Enter Last Name:','s');
s1=strvcat(f,l)
if( strcmpi(f,'Jed') );
break
end
end
I need help here. My goal with this code is to be able to store names using the command strvcat. However, I'm having trouble integrating it. Any suggestions?
  댓글 수: 4
TS
TS 2015년 4월 29일
Ok, so basically I would like a 2 column matrix with first and last names next to each other.
TS
TS 2015년 4월 29일
And yes, I would like to accumulate first and last names.

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

채택된 답변

James Tursa
James Tursa 2015년 4월 29일
E.g., using a cell array of strings,
names = cell(0,2);
while (true)
f=input('Enter First Name:','s');
l=input('Enter Last Name:','s');
names(end+1,:) = {f l};
if( strcmpi(f,'Jed') );
break
end
end

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by