Filter löschen
Filter löschen

how to plot cell ?

1 Ansicht (letzte 30 Tage)
Tomas
Tomas am 12 Nov. 2013
Kommentiert: Tomas am 12 Nov. 2013
I have for example cell {1x1 cell} {1x7 cell} {1x2 cell}, each cell is cluster.
I have to plot each cluster, how to plot together in one figure ?
Thanks
  2 Kommentare
Walter Roberson
Walter Roberson am 12 Nov. 2013
Bearbeitet: Walter Roberson am 12 Nov. 2013
What is the data structure inside the cells? For example is it an array of XYZ coordinates? Are you wanting to scatter3() based on the coordinates?
Tomas
Tomas am 12 Nov. 2013
ans = Z{1}
[1x3 double]
ans = Z{2}
Columns 1 through 6
[1x3 double] [1x3 double] [1x3 double] [1x3 double] [1x3 double] [1x3 double]
Column 7
[1x3 double]
ans = Z{3}
[1x3 double] [1x3 double]
I want to differentiate the color each Z{1} Z{2} Z{3}
Thanks

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 12 Nov. 2013
pointsize = 10;
nclust = length(Z);
colorfrac = linspace(0, 1, nclust);
clustcoords = cellfun( @cell2mat, Z, 'Uniform', 0 );
for k = 1 : length(clustcoords)
XYZ = clustcoords{k};
scatter3(XYZ(:,1), XYZ(:,2), XYZ(:,3), pointsize, colorfrac(k));
hold on
end
  3 Kommentare
Walter Roberson
Walter Roberson am 12 Nov. 2013
nclust = length(Z);
thismap = copper(nclust); %or pink or flag or hot or ...
clustcoords = cellfun( @cell2mat, Z, 'Uniform', 0 );
for k = 1 : length(clustcoords)
XYZ = clustcoords{k};
plot3(XYZ(:,1), XYZ(:,2), XYZ(:,3), thismap(k,:));
hold on
end
Tomas
Tomas am 12 Nov. 2013
??? Error using ==> plot3 Data must be a single matrix Y or a list of pairs X,Y
Error in ==> knew at 107 plot3(XYZ(:,1), XYZ(:,2), XYZ(:,3), thismap(k,:));

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by