Name Storing in a While Loop
显示 更早的评论
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
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
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
2015-4-29
TS
2015-4-29
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!