Plotting a matrix of vector to the index with different makers for all vectors

1 view (last 30 days)
Oscar Schyns on 24 Nov 2020
Answered: Ritvik Garg on 15 Jun 2021
Hi MATLAB,
I am trying to plot all 10 vectors in Matrix X (10,51) with the index (range 1:51) on the X axis and the values for all 10 vectors on the Y axis.
I use this code: plot(X'),
I am trying to make the plot also clear in black and white but that has not succeeded yet. I understand there are only 4 types of line styles so I think I should work with markers. The goals is thus to have different markers for all 10 vectors and only showing them every 5 iterations/index (so on x axis = 5,10,15,20.....). Is there a way to do that in a clear way, without splitting the matrix in 10 different vectors and combining the plots (takes alot of time and I have many matrices with all different dimensions). A problem is that if I do split it in different vectors I also need to add [1:51] to all these vectors so that the plot function understand that I want the index on the x axis.
Oscar

Ritvik Garg on 15 Jun 2021
Hi Oscar,
You can do this task using set, which helps in setting object properties.
Here’s an example of plotting a matrix with 5 different markers for 5 vectors each of length 20, marking at every 5th iteration.
a = rand(5,20);
p = plot(a');
set(p, {"Marker"}, {'+';'o';'*';'x';'v';}, 'MarkerIndices', 5:5:20);
legend; Hope this helps.