Filter löschen
Filter löschen

Name Storing in a While Loop

1 Ansicht (letzte 30 Tage)
TS
TS am 29 Apr. 2015
Beantwortet: James Tursa am 29 Apr. 2015
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 Kommentare
TS
TS am 29 Apr. 2015
Ok, so basically I would like a 2 column matrix with first and last names next to each other.
TS
TS am 29 Apr. 2015
And yes, I would like to accumulate first and last names.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

James Tursa
James Tursa am 29 Apr. 2015
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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by