MATLAB: Multiple graphs for two or more functions for different values in different color

MATLABmultipleplot

n=2; y1=0.5 (q.^2*n-5*q.^n+(2*q-1).^(n+3)) y2=0.5(q.^2*n-7*q.^n+2*(2*q-1).^(n+4))
i want to plot the graphs(in one figure) of above two or more functions for the different values of q>=2 for example these values can be q=2,3,,4,5

Best Answer

n=2;
q=2:5
y1=0.5.*(q.^2.*n-5.*q.^n+(2.*q-1).^(n+3))
y2=0.5.*(q.^2.*n-7.*q.^n+2.*(2.*q-1).^(n+4))
y3=(1/12).*(4.*q.^n-1-9*q.^n + 3.*(2.*q-1).^(n+9))
y4=2.*(q.^n-2).*(q.^2*n-3.*q.^n+(2*q-1).^n + 1)
y5=0.5.*(q.^2.*n-4.*q.^n-(2.*q-1).^n+3)
subplot(5,1,1)
plot(q,y1,'-r','LineWidth', 2)
subplot(5,1,2)
plot(q,y2,'-b','LineWidth', 2)
subplot(5,1,3)
plot(q,y3,'-k','LineWidth', 2)
subplot(5,1,4)
plot(q,y4,'-y','LineWidth', 2)
subplot(5,1,5)
plot(q,y5,'-g','LineWidth', 2)