![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177729/image.jpeg)
Cirle with color changing gradually.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hoang Phuc Ho
le 17 Juil 2015
Commenté : Aboozar Garavand
le 19 Mar 2017
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152272/image.png)
How can I plot a circle like this in matlab, please give me an example. Thanks in advance.
0 commentaires
Réponse acceptée
arich82
le 17 Juil 2015
Modifié(e) : arich82
le 17 Juil 2015
[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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177729/image.jpeg)
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 commentaires
Walter Roberson
le 18 Mar 2017
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.
Plus de réponses (1)
Walter Roberson
le 18 Mar 2017
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.
1 commentaire
Voir également
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!