Script switch_and_cell.m
Download Script switch_and_cell.m
values={10,3,'<word>'};
for i=1:3

switch values{i}
case 1
disp('the value is 1')
case {2,3,4}
switch values{i}
case 3
disp('the value 3 was found')
case 2
disp('the value 2 was found')
case 4
disp('the value 4 was found')
end
case '<word>'
disp('the string <word> was found')
otherwise
disp('any values was found in the block')
end
end
Back