I have a matrix with 360 columns. I want a 3D plot in which at every 1 degree one column is be ploted with diferent color. Can anyone suggest how to proceed? Let me know if you need further explaination about my problem?

2 visualizzazioni (ultimi 30 giorni)
Let me know if you need further explaination about my problem?
  5 Commenti
Sanjeev Kumar Singh
Sanjeev Kumar Singh il 1 Giu 2015
Thank you Walter for a quick response. Actually plotting with is different color is not my main purpose. It may contain RGB alternatively also. And yes, at every on degree angle the values is that column represent z coordinates.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 1 Giu 2015
I have doubts that what you ask is going to turn out looking at all useful, but here is code for what you asked.
R = 500; %adjust to look right
[nrow, ncol, panes] = size(YourMatrix);
assert(panes==1, 'Code not designed for 3D matrices');
%set an N x 3 RGB array "colortab" to be your 360 different colors. This
%needs to be done in RGB because MS Windows supports a maximum of 256
%entries in normal colormapping.
colortab = colormap(hsv(ncol));
%complete the circle and then drop the last point so last column is
%not on top of the first
angles = linspace(0,360,ncol+1) * pi/180; %row vector
[x,y] = pol2cart(angles(1:ncol), R);
X = repmat(x, nrow, 1);
Y = repmat(y, nrow, 1);
lines = plot(X, Y, YourMatrix); %draw in columns
for K = 1 : length(lines)
set(lines(K), 'Color', colortab(K,:)); %set the colors
end
drawnow();
  4 Commenti
Walter Roberson
Walter Roberson il 1 Giu 2015
As a line plot:
R = 500; %adjust to look right
[nrow, ncol, panes] = size(YourMatrix);
assert(panes==1, 'Code not designed for 3D matrices');
colortab = colormap(hsv(ncol));
angles = linspace(0,360,ncol+1) * pi/180; %row vector
[X,Y] = pol2cart( repmat(angles(1:ncol),nrow,1), YourMatrix);
Z = repmat((1:nrow).', 1, ncol);
lines = plot3(X, Y, Z, '*-');
for K = 1 : length(lines)
set(lines(K), 'Color', colortab(K,:)); %set the colors
end
You might at this point also have a look at
ct = repmat(reshape(colortab,1,ncol,3), nrow, 1, 1);
mesh(X,Y,Z,ct);
Image Analyst
Image Analyst il 1 Giu 2015
Sanjeev, is there some reason why you won't upload a picture of what you want? Why make us guess? Walter is more generous than me - I'm not going to guess at code you might want until I see what you want.

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by