how do I plot different 3D peaks in different locations in single polar plot
조회 수: 3 (최근 30일)
이전 댓글 표시
In the image shown below I have a peak at center in polar plot. I need like that six peaks surrounding this main peak. Surrounding these six peaks I need nine peaks. To put it simply, in K shell I need 6 peaks, in L shell I need 9 peaks with central peak intact. I need them all in polar plot only.
thanks for help
댓글 수: 2
dpb
2019년 7월 15일
Please attach the jpg w/ the picture icon instead of as a paperclip download file...
채택된 답변
Star Strider
2019년 7월 15일
Try this:
N = 500;
rv = linspace(0, 1, N); % Radius Vector
av = linspace(0, 2*pi, N); % Angle Vector
Ka = linspace(2*pi/12, 2*pi-2*pi/12, 6); % ‘K’ Angles
La = linspace(2*pi/18, 2*pi-2*pi/18, 9); % ‘L’ Angles
[R,A] = meshgrid(rv, av);
pkf = @(s) exp(-((((-15:15)).^2) + (((-15:15)).^2)')/s); % Creates Gaussian Peaks
Mf = @(M,r,c) M((-15:15)+r,(-15:15)+c); % Matrix Coordinates Grid For Each Peak
figure
[Xb,Yb,Zb] = pol2cart(A,R,zeros(size(R))); % Base Plane
surf(Xb,Yb,Zb)
hold on
surfc(Mf(Xb,16,16), Mf(Yb,16,16), pkf(50)*0.75) % Center Peak
for k = 1:numel(La) % ‘L’ Peaks
Rrow = 400;
ix = find(av <= La(k), 1, 'last');
[X(:,:,k),Y(:,:,k),Z(:,:,k)] = pol2cart(Mf(A,ix,Rrow),Mf(R,ix,Rrow),pkf(2)*0.25);
surf(X(:,:,k),Y(:,:,k),Z(:,:,k))
end
for k = 1:numel(Ka) % ‘K’ Peaks
Rrow = 200;
ix = find(av <= Ka(k), 1, 'last');
[X(:,:,k),Y(:,:,k),Z(:,:,k)] = pol2cart(Mf(A,ix,Rrow),Mf(R,ix,Rrow),pkf(5)*0.5);
surf(X(:,:,k),Y(:,:,k),Z(:,:,k))
end
hold off
shading interp
grid on
axis equal
view(-40,25)
producing:
![how do I plot different 3D peaks in different locations in single polar plot - 2019 07 15.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/229909/how%20do%20I%20plot%20different%203D%20peaks%20in%20different%20locations%20in%20single%20polar%20plot%20-%202019%2007%2015.png)
The grids are defined as (-15:15) for every peak and the coordinate arrays for them. If you change those dimensions, you will need to change them in both the ‘pkf’ and ‘Mf’ functions, as well as in the ‘Center Peak’ plot. The rest of the code should adapt automatically, although within limits.
Experiment to get the result you want.
댓글 수: 7
Star Strider
2019년 7월 16일
Rakesh V’s Answer moved here:
Dear SS,
I am using the same code which you have written to generate polar plot. I am using 2014b which our university provided us. That is the reason why i am unable to use the code.
The error was at this point.
pkf = @(s,a) exp(-((((-15:15)).^2) + (((-15:15)).^2)')/s)*a; % Creates Gaussian Peaks
If I remove the transpose in the above equation it executes.
hence i had the problem it seems.
Anyhow i will work it from here
Thanks and regards for the help.
Star Strider
2019년 7월 16일
My pleasure.
You did not descirbe the specific problems you are having. There may be ways to solve them if I know what they are.
My code works in 2019a, and does what you describe what you want it to do, following your original post.
If my Answer helped you solve your problem, please Accept it!
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!