clc, close all, clear all

x=linspace(0,1,500);
hold on

for n=1:4
    y=x.^n;
    plot(x,y)  
end % for

legend('n=1','n=2','n=3','n=4','Location','best')
xlabel('x')
ylabel('y')
title('Without switch-case')

figure
hold on

for n=1:4
y=x.^n;  

    switch n
        case 1
            s='b';
        case 2
            s='r';
        case 3
            s='g';
        case 4
            s='m';
    end % switch     
    
plot(x,y,s)

end % for

legend('n=1 (blue)','n=2 (red)','n=3 (green)','n=4 (magenta)','Location','best')
xlabel('x')
ylabel('y')
title('With switch-case')