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 Exchange에서 2-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