MATLAB: Name Storage with Repeat loops

name storagerepeat loops

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.

Best Answer

  • 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