How can I plot data in one matrix and color the data differently using data from another matrix?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi !
I have a matrix with "data" with size n by 2. this matrix rows contain some value that I want to plot.
and another matrix with size "R" n by k. this matrix contain ones and zero. the sum of each row is one.
the matrix R indicate each row of data follows which colunm out of the k columns.
for example:
data =[1 2; 2 4 ; 3 6;4 7];
R= [0 1 0 0; 0 0 1 0; 0 1 0 0; 1 0 0 0];
now I want to plot the matrix data
plot(data(:,1),data(:,2),'o');
but I want the points colours to be diffrent according to which column of R contain the 1.
in the example I will have the 1st data points and the last ones with the same color. and the others are diffrent.
also the number of columns in R = k >= 2 ( but not necessarily 3)
How can I do this ??
thank you.
0 件のコメント
回答 (1 件)
KSSV
2019 年 5 月 2 日
data =[1 2; 2 4 ; 3 6;4 7];
R= [0 1 0; 0 0 1; 0 1 0; 1 0 0];
figure
hold on
for i = 1:size(data,1)
plot(data(i,1),data(i,2),'.','MarkerSize',50,'color',R(i,:))
end
Have a look on scatter also.
3 件のコメント
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!