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?

Let me know if you need further explaination about my problem?

5 Commenti

You want the columns placed around the outside of a circle, right? For any given column, what should the values in the column represent? Should they represent z coordinates? If so then each one would represent a straight line (that might double back on itself) and the only distinguishing attribute of the points would be the markers.
You do realize that 360 different colors will be difficult to distinguish? Or, you could alternate the standard colors, but then they won't be different.
If you can upload a sample picture of what you'd like to obtain, it would really help us visualize what you want.
Put the question in the question box, not the title...
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)

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

I suspect that what you want is more like these lanterns, where differences in your coordinates reflect differences in radius.
more like the same. but every strip here(a 3d curve in my case) in the lantern should represent one of the columns in the matrix.
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);
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 Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by