How to plot 2D ring with surf ?

12 ビュー (過去 30 日間)
Maxime Dubart
Maxime Dubart 2017 年 1 月 12 日
コメント済み: Janani Shekar 2021 年 5 月 7 日
Hi !
I'm currently writing a code of the distribution of an electrical potential as a function of the radius r (as seen in the picture below) and the angle alpha (the angle of the circle, from 0 to 2pi) for a physic problem.
Using the function surf, I can plot the values of this potential at a certain time, as a function of alpha and psi, the radius, but it displays them in a square :
What I would like is to display the same graph, but as a ring form, just like the first picture, so it is more easy to picture the exact place inside the ring the corresponding potential is.
I have currently no idea how to begin. I would really appreciate your help !
Thanks a lot in advance, Best Regards.

回答 (1 件)

Vandana Ravichandran
Vandana Ravichandran 2017 年 1 月 20 日
編集済み: Vandana Ravichandran 2017 年 1 月 20 日
You can get started with the following example. Here we are obtaining the width and height of the figure using "Position" property. Using this we are able to calculate the center coordinates. We can draw circles using "viscircles" function, for a given center and radius.
f = figure;
axes = gca;
axes.Visible = 'off';
pos = f.Position;
w = pos(3);
h = pos(4);
center = [w/2 h/2];
viscircles(center,4,'Color','r');
viscircles(center,2.5,'Color','b');
  1 件のコメント
Janani Shekar
Janani Shekar 2021 年 5 月 7 日
Hi, can you explain this code in detail?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by