I'm really new to MATLAB so I apologise in advance for my simple question. But I'm trying to construct a plot of 5 different sine waves, & my code looks like this:
x=0:pi/100:2*pi;y1=sin(x);plot(x,y1);hold ony2=sin(2*x);plot(x,y2)y3=sin(3*x);plot(x,y3)y4=sin(4*x);plot(x,y4)y5=sin(5*x);plot(x,y5)
I'd like to learn how to tidy this up a bit by using a loop in place of manually adding each next sine wave, but I can't figure out how for the life of me, & would really appreciate some help or advice.
Best Answer