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 vues (au cours des 30 derniers jours)
Let me know if you need further explaination about my problem?
  5 commentaires
dpb
dpb le 30 Mai 2015
Put the question in the question box, not the title...
Sanjeev Kumar Singh
Sanjeev Kumar Singh le 1 Juin 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.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 1 Juin 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 commentaires
Walter Roberson
Walter Roberson le 1 Juin 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 le 1 Juin 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by