MATLAB: Write a script that will keep prompting the user for a string then stores them in a cell array and prints to display all strings in this cell array:

cell arraycelldispstring

string=input('PLEASE INPUT A STRING:','s');
string1={i}
I believe I would need a for loop and to use celldisp but I am having trouble figuring out how to do those.

Best Answer

Try this:
maxCount = 10; % a "Failsafe"
counter = 1; % Failsafe.
while counter <= maxCount
string = input('PLEASE INPUT A STRING (Type quit to exit):', 's');
if ~isempty(strfind(lower(string), 'quit'))
break;
end
strings{counter} = string
counter = counter + 1;
end
fprintf('Done!\n');
celldisp(strings);