How to create a 2D circular intensity plot?

Hi, I can generate 2D plots like in the image above in comsol. I want to generate the same in matlab. This is a plot of electric field distribution in a cylindrical resonator. My matlab code has the electric field as a function of radius and angle. May be creating a meshgrid and then using polar command might be the way to go but I am not sure how to do that correctly. Any suggestion or link would be appreciated. Thanks </matlabcentral/answers/uploaded_files/22752/snapshot.png>

回答 (2 件)

Thorsten
Thorsten 2014 年 12 月 18 日
編集済み: Thorsten 2014 年 12 月 18 日

1 投票

Define your X Y Cartesian coordinates with meshgrid, convert to radius and angle
R = sqrt(X^2 + Y^2);
A = atan2(Y, X);
and run your function on R and A.
Zeba
Zeba 2014 年 12 月 19 日

0 投票

Thanks for your reply! I am sorry, I meant Electric field values are calculated and stored in a matrix. So I know what's the field at a given radius and angle. I used the following snippet to make it work axes(handles.axes2)
[rr, tt]=meshgrid(linspace(0,2*r(1),length(y)), linspace(0,2*pi,length(y)));
xx=rr.*cos(tt);
yy=rr.*sin(tt);
hh=polar(xx,yy);
zz=(repmat(y,length(y),1).*cos(m*tt)).^2;
hold on; pcolor(xx,yy,zz); shading interp; set(hh,'visible', 'off');
axis off
axis image I had found part of it on some webpage while searching for help. When I try to change the colorbar range, I get an error Error using set
Bad property value found.
Object Name: axes
Property Name: 'CLim'
Values must be increasing and non-NaN.
The code for the up and down pushbuttons in the figure below is
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
color_range=get(handles.axes2,'Clim');
newcolor_range=[color_range(1)*2 0];
set(handles.axes2,'Clim',newcolor_range)
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
color_range=get(handles.axes2,'Clim');
newcolor_range=[color_range(1)/2 0];
set(handles.axes2,'Clim',newcolor_range)
How do I get rid of this error while changing colorbar range? It works with normal axes. Thanks

4 件のコメント

Thorsten
Thorsten 2014 年 12 月 19 日
This is a new question. Please accept my answer and start a new question with a new title that better reflects your current problem.
Zeba
Zeba 2014 年 12 月 19 日
I figured out the problem. Thanks
Thorsten
Thorsten 2014 年 12 月 20 日
Please formally accept my answer if it was helpful.
MatlabUser
MatlabUser 2022 年 2 月 18 日
can you please share the working code with intensity input thing?

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

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2014 年 12 月 18 日

コメント済み:

2022 年 2 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by