MATLAB: How to change the case to a string so when I run the script the the string instead of the case number is shown

stringswitch case

m=menu('select shape:', 'triangle','square','pentagon','hexagon','heptagon','octagon')
switch m
case 1
n=3
angle=(n-2)*180
case 2
n=4
angle=(n-2)*180
case 3
n=5
angle=(n-2)*180
case 4
n=6
angle=(n-2)*180
case 5
n=7
angle=(n-2)*180
case 6
n=8
angle=(n-2)*180
end
fprintf('A %-5.2f has %-5.2f sides and %-5.2f degrees\n',m,n,angle)
>> Untitled
m =
1
n =
3
angle =
180
A 1.00 has 3.00 sides and 180.00 degrees

Best Answer

I believe you want:
fprintf('A %s has %d sides and %-5.2f degrees\n',m,n,angle)