How to I plot this?

Hello, I have a matrix, X, in which I want to plot it using the kmeans function. What I would like: If row has a value of 1 in column 4 I would like it to be square shaped If the row has a value of 2 in column 4 I would like it + shaped BUT If the row has a value of 0 in column 5 it must be blue and if the row has a vale of 1 in column 5 it must be yellow
(You don't need to sue these exact colors and shapes, I just want to distinguish these.) I tried this and it did not work:
plot(X(idx==2,1),X(idx==2,2),X(:,4)==1,'k.');
Thanks!!

답변 (1개)

Evan
Evan 2013년 7월 11일

1 개 추천

Does this do what you need?
X = [1 2 3 1 1;
6 6 6 2 1;
9 8 7 1 0;
3 3 3 2 0];
hold on
plot(X(X(:,4)==1 & X(:,5)==1,:),'sy')
plot(X(X(:,4)==1 & X(:,5)==0,:),'sb')
plot(X(X(:,4)==2 & X(:,5)==1,:),'+y')
plot(X(X(:,4)==2 & X(:,5)==0,:),'+b')

댓글 수: 3

Z
Z 2013년 7월 11일
That didn't work for me, but this did:
plot(X(X(idx==2,a)==1,1),X(X(idx==2,a)==1,2),'g+','Markersize',12)
Evan
Evan 2013년 7월 11일
And did that actually give you different marker colors and types like you requested? I don't see how the code you posted could be doing that.
Z
Z 2013년 7월 11일
편집: Z 2013년 7월 11일
Yeah, it did (I changed the numbers a bit to actually mit my matrix.)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

제품

질문:

Z
Z
2013년 7월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by