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

11 ビュー (過去 30 日間)
Oscar Schyns
Oscar Schyns 2020 年 11 月 24 日
回答済み: Ritvik Garg 2021 年 6 月 15 日
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.
Thank you for your time,
Oscar

採用された回答

Ritvik Garg
Ritvik Garg 2021 年 6 月 15 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by