- fill: https://in.mathworks.com/help/matlab/ref/fill.html
- pol2cart: https://in.mathworks.com/help/matlab/ref/pol2cart.html
Creating a shaded region on the polarplot
29 次查看(过去 30 天)
显示 更早的评论
Hello, I am trying to display a curve and a shaded region on the same polarplot. To create shaded region I used the polarhistogram as given below
polarhistogram([5.*pi/6 ,pi],1,BinLimits=[5.*pi/6,pi],EdgeAlpha=0,FaceAlpha=0.2,FaceColor=[0.4660 0.6740 0.1880])% creates a shaded region
Which does the job. I would like to display this on the polar graph generated by the code below
clear all;
tic
pr=6250000000000000000000000./(2669354663220513.* pi.^2);zr=pi.*800;
omega=3.*pi./4;tau=25;c=300;E0=0.0026./sqrt(10); %parameters
s12pmp = @(thetak,k,z) zr.^2.*tau./2.*c./omega.*E0.^3.*pi.^(3./2).*1./sqrt(3).*exp(-32.*z.^2.*zr.^2./(3.*c.^2.*tau.^2)+1i.*(-2+2+4).*z.*zr.*omega./(3.*c)....
+ 1./3*1i.*k.*z.*zr.*(-1+3.*cos(thetak))-c.*k.^2.*(1+z.^2).*zr.*sin(thetak).^2./(2.*omega.*(3+1i.*(-1).*z)))...
*((1+1i.*z)./(1-1i.*z)).^(1./2.*(-1)).*2./((3+1i.*(-1).*z).*sqrt(1+z.^2));
s12pmpz = @(thetak,k) integral(@(z) s12pmp(thetak,k,z),-Inf, Inf,'ArrayValued',true);
s12pmpzk = @(thetak) integral(@(k) pr.*4.*2.*pi.*k.^3.*exp(-1./24.*tau.^2.*(c.*k-omega).^2).*sin(thetak./2).^4.*sin(thetak) ...
.*abs(s12pmpz(thetak,k)).^2, pi./500, pi./300,'ArrayValued',true);
figure();
% hold on
n=200;
thetak = linspace(0,pi,n);
polarplot(thetak,s12pmpzk((thetak)))
thetalim([0 180]);
%colorbar('southoutside')
timeElapsed = toc
Any help is greatly appreciated.
0 个评论
回答(1 个)
Poorna
2023-9-12
Hi Cesim Dumlu,
I understand that you want to shade/fill the polar plot just like the "polarhistogram" function.
You can do this by using the "fill" function. But the "fill" function only takes cartesian coordinates as input. So, you might want to use the "pol2cart" function to convert the polar coordinates to cartesian coordinates.
An example code is given below. Here, first we convert the theta and rho values to cartesian coordinates using "pol2cart" function. Later, use the "fill" function to shade the plot with required the colour
rhodata = s12pmpzk((thetak));
%convert the polar coordinates to cartesian.
[x,y] = pol2cart(thetak, rhodata);
%fill the plot with the required color
fill(x,y,[0.4660 0.6740 0.1880], 'FaceAlpha', 0.2);
And at last, to plot a polar plot and a cartesian plot in the same axes, you might want to refer to the following answer: https://in.mathworks.com/matlabcentral/answers/400591-how-do-i-combine-the-polar-plot-and-cartesian-coordinate-together#answer_320079
Kindly refer to the following links to know more about the functions used above:
Hope this Helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!