2
votes

I have a matrix with sample points from different classes. Let's say they are features from 10 subjects, and there are 80 samples per subject.

So I have a 800 x 3 matrix.

I want to plot it using the rows as 3D points, so I use this :

hold on;
for i=1:length(m)
plot3(m(i,1) , m(i,2) , m(i,3) , 'r*');
end

this works but the argument 'r*' plots all the points as red asterisks.

But I want to plot every class as a different color. So whenever i%80==0 I need to change the color argument with an RGB vector. How can I do this?

Thanks for any help!

1

1 Answers

5
votes

I found the answer. You simply need to plot the points like this :

plot3(m(i,1) , m(i,2) , m(i,3) , 'Color' , [0.5 0.5 0] , 'Marker' , '*');

or

plot3(m(i,1) , m(i,2) , m(i,3) , 'Color' , [r g b] , 'Marker' , '*');