Drawing a circle of ones by using a pre-defined grid with pcolor

조회 수: 6 (최근 30일)
Sahin Kurekci
Sahin Kurekci 2019년 9월 14일
댓글: Sahin Kurekci 2019년 9월 14일
I have the following grid in the beginning of my code:
a = 25, % This will be the radius of the circle
r = linspace(0,sqrt(2)*2*a,501);
phi = linspace(0,2*pi,501);
[R,Phi] = meshgrid(r,phi);
X = R.*cos(Phi);
Y = R.*sin(Phi);
And I plot all my figures by using the code segment:
figure()
h = pcolor(X,Y,abs(u_sum).^2); % u_sum is an electric field distribution
set(h,'EdgeColor','none');
box on
grid on
axis equal
xlim([-1,1]*r(end)/sqrt(2));
ylim([-1,1]*r(end)/sqrt(2));
colormap(hot);
colorbar;
xlabel('x');
ylabel('y');
title(['Title'])
hold on
rectangle('Position',[-1,-1,2,2]*a,'Curvature',1,...
'LineWidth',1,'EdgeColor','w','FaceColor','None',...
'LineStyle','--')
hold off
set(gca,'Layer','top')
The output of this code is:
pcolor_circle.jpg
Now, I want to draw a circle full of ones with radius "a" and place it on the same grid. Thus, I want the circle at the center of the above picture to be filled with ones, and zeros at rest. How can I do that using pcolor and the same grid?
Alternatively, how can I implement a Gaussian shape for the same grid using pcolor?

채택된 답변

darova
darova 2019년 9월 14일
Z1 = R <= a^2; % place ones
Gauss shape
9d128aef1457349d67843e863bf84aaf24f66ecf
Place R isntead of x
  댓글 수: 5
Sahin Kurekci
Sahin Kurekci 2019년 9월 14일
Of course... That is a very naught square there. Thanks.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by