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 件のコメント

the cyclist
the cyclist 2015 年 4 月 29 日
I think you are close. If someone entered
f = Tommy
l = Thomas
then
f = Sally
l = Sampson
then
f = Jed
l = Jameson
what do you want your final output to look like?
James Tursa
James Tursa 2015 年 4 月 29 日
We need more detail. As written, s1 gets overwritten at each iteration, so it is not clear what you want as a final result. Do you want to accumulate all of the first & last name inputs into a single variable? E.g., a cell array of strings?
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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

TS
2015 年 4 月 29 日

回答済み:

2015 年 4 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by