MATLAB How to Plot Multiple Matrices with Different Colors in Matlab?

Click For Summary
To plot multiple matrices in MATLAB, each representing a set of points with x and y coordinates, use the command "hold on;" to allow for multiple plots on the same figure. For each matrix, the plotting command should be structured as "plot(matrix(1,:), matrix(2,:))" to correctly reference the x and y coordinates. To differentiate each dataset by color, utilize the "hold all;" command, which automatically assigns different colors to each successive plot. For further customization, including changing line colors, refer to the MATLAB documentation for detailed instructions.
Funzies
Messages
20
Reaction score
0
Hey guys, I'm having some trouble plotting a matrix.
I have a cell in which I've put four matrices. These matrices are variable in length: they are nx2 with n starting on 31 and varying from 0 to 120. De first column of each matrix represents the x-coordinate and the second column represents the y-coordinate from a point.
I want to plot these four matrices pointwise and fit lines through them, each having a different colour. Can anyone help me with this code? I can't seem to find the way in the Matlab help browser..
 
Physics news on Phys.org
For multiple plots, use
Code:
hold on;

To plot the matrices, for each matrix use something like
Code:
plot(matrix(1,:),matrix(2,:))

You should be able to find how to change line colors in the online MATLAB docs.
 
hold all;

will plot each successive dataset in a different colour.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K