v = input('Continue?', 's');
while strcmpi(v,'y')
disp(rand)
v = input('Continue?', 's');
end
When applied to character vectors the equivalence operator == performs an element-wise comparison (as it does on all array types). To compare the complete character vector, use strcmp or strcmpi.