Want to create colors depending on the number of columns i got in my X

1 回表示 (過去 30 日間)
Tiago Dias
Tiago Dias 2018 年 11 月 26 日
編集済み: Jan 2018 年 11 月 27 日
Hello, i want to plot each column, and i want to associate each column with a color but automaticly.
X = [1:26]';
Y = [1:26]';
[n,m] = size(X);
rows = 3;
columns = ceil(n/rows);
extra_row = columns * rows;
X(n+1:extra_row) = NaN;
X_new = reshape(X,rows,columns)
So, if i put a different numbe ron "ROWS" my "X_NEW" will have more or less columns.
Question -> How to create a vector of colors or string of colors depending on the number of columns of X_new?
Thanks for your time

採用された回答

Jan
Jan 2018 年 11 月 26 日
What about:
CMap = parula(rows)
  5 件のコメント
Tiago Dias
Tiago Dias 2018 年 11 月 27 日
oh ok. I place with a vector
plot(1:10, rand(1,10), '*', 'Color', [CMap(k,1) CMap(k,2) CMap(k,3)]);
thanks!
Jan
Jan 2018 年 11 月 27 日
編集済み: Jan 2018 年 11 月 27 日
CMap(k, :) is the abbreviation for CMap(k, 1:3), which is exactly the same as [CMap(k,1) CMap(k,2) CMap(k,3)], so I'd prefer the leaner notation.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by