Cirle with color changing gradually.

조회 수: 6 (최근 30일)
Hoang Phuc Ho
Hoang Phuc Ho 2015년 7월 17일
댓글: Aboozar Garavand 2017년 3월 19일
How can I plot a circle like this in matlab, please give me an example. Thanks in advance.

채택된 답변

arich82
arich82 2015년 7월 17일
편집: arich82 2015년 7월 17일
[Edited to add colorbar and image.]
As far as I know, you can't do it directly, but pol2cart is your friend. Look at
and maybe
% construct grid of polar coords
th = (0:5:360)*pi/180;
r = 0:.05:1;
[TH, R] = meshgrid(th, r);
% convert polar to cartesian
[X, Y] = pol2cart(TH, R);
% dummy function plotted over X Y data
Z = X + 1i*Y;
f = abs((Z.^4 - 1).^(1/4));
% use overhead view of surf plot for figure
figure;
surf(X, Y, f);
view(2);
axis equal;
axis square;
colorbar('SouthOutside');
colormap('Jet');
Note that axis(2) gives an overhead view, so it looks like a flat circle, and axis equal ensures it looks like a circle and not a distorted ellipse.
Please accept this answer if it helps, or let me know what's wrong in the comments.
  댓글 수: 6
Hoang Phuc Ho
Hoang Phuc Ho 2015년 8월 5일
Thank you so much. It worked! :)
Walter Roberson
Walter Roberson 2017년 3월 18일
Unfortunately, surf() is not compatible with the new-ish polaraxes (R2016a and later).
You could use the older polar() to create the basic background graphic, and then "hold on", and then plot on top of it.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 3월 18일
The File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/17933-polar-to-from-rectangular-transform-of-images transforms rectangular images to and from polar to achieve the effect this Question is about.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by