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 (최근 30일)
Let me know if you need further explaination about my problem?
  댓글 수: 5
Sanjeev Kumar Singh
Sanjeev Kumar Singh 2015년 6월 1일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 6월 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
Walter Roberson
Walter Roberson 2015년 6월 1일
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 2015년 6월 1일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by