I want to create a loop that will iterate over several strings, but unable to do so in Matlab.
What works is:
for i=1:3 if (i==1) b=\'cow\'; else
Sure! Use cell arrays for keeping strings (in normal arrays, strings are considered by character, which could work if all strings have the same length, but will bork otherwise).
opts={'cow','dog','cat'} for i=1:length(opts) disp(opts{i}) end