MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Thread Subject: Plotting multiple lines on the same graph

 Subject: Plotting multiple lines on the same graph From: Ulrik Nash Date: 14 Oct, 2011 19:22:27 Message: 1 of 2 Hello, I am trying to plot the content of column vectors in matrix A on the same graph. I was hoping the following would work, but only the line for the last vector remains: for i = numel(A(1,:)) y = A(1:10,i); x = 1:10; plot(x,y) hold all end What would be a better way to achive my aim? Regards, Ulrik.
 Subject: Plotting multiple lines on the same graph From: Diego Torquemada Date: 14 Oct, 2011 19:40:10 Message: 2 of 2 On Oct 14, 2:22 pm, "Ulrik Nash" wrote: > Hello, > > I am trying to plot the content of column vectors in matrix A on the same graph. I was hoping the following would work, but only the line for the last vector remains: > > for i = numel(A(1,:)) > y = A(1:10,i); > x = 1:10; > plot(x,y)     > hold all > end > > What would be a better way to achive my aim? > > Regards, > > Ulrik. Simply do the following: x = 1:10; A = rand(10,5); plot(x,A) As you see this plots five lines, each corresponds to a column of A Regards, Diego