The the interpolate on the spherical coordinate system
Show older comments
I want to make a structure(eg: r=cos^10(theta)) in the spherical coordinate system and plot the combination of (orginal pattern+rotota 90 pattern)
So I planed to transfer it to cartesian coordinate system firstly. (In the cartesian coordinate system, the pattern rotation is much easier).
close all;
clear all;
THETA_1 = (1e-9:0.01:pi);
PHI_1 = 1e-9:0.01:2*pi;
[theta_1,phi_1] =meshgrid(THETA_1,PHI_1);
%%
% Pattern and rotate
Pattern=cos(theta_1).^10;
patch_dB = 10*log10(abs(Pattern).^2);
Rlim = -30;
patch_dB_temp = patch_dB - Rlim;
patch_dB_temp(patch_dB_temp < 0) = 0;
X_patch_1 = Pattern.*sin(theta_1).*cos(phi_1);
Y_patch_1 = Pattern.*sin(theta_1).*sin(phi_1);
Z_patch_1 = Pattern.*cos(theta_1);
figure(1)
surf(X_patch_1,Y_patch_1,Z_patch_1,'EdgeColor','interp');
figure(3)
surf(X_patch_1,-Z_patch_1,Y_patch_1,'EdgeColor','interp');
Now, we can obtain the rotate 90 degree plotting(figure 3) and original plotting(figure 1).
However, the data point location is also changed and I can not combine them together.

Acutally, we need to get the same data point location with rotate 90 degree pattern(as followed), so i tried to get the corresponding value in the previous point location by interpolating.

But it shows the error:
Error using interp2>makegriddedinterp (line 237)
Input grid is not a valid MESHGRID.
%% Transfer to spherical coordinate system and check the plotting
[azimuth,elevation,r]= cart2sph(X_patch_1,-Z_patch_1,Y_patch_1);
figure(2)
theta_2=pi/2-elevation;
phi_2=azimuth+pi;
X_patch_2 = r.*sin(theta_2).*cos(phi_2);
Y_patch_2 = r.*sin(theta_2).*sin(phi_2);
Z_patch_2 = r.*cos(theta_2);
% plot3(X_patch_2,Y_patch_2,Z_patch_2,'o')
surf(X_patch_2,Y_patch_2,Z_patch_2,'EdgeColor','interp');
%%
%%Sample the value
THETA = (1e-9:0.01:pi);
PHI = (1e-9:0.01:2*pi);
[theta,phi] =meshgrid(THETA,PHI);
interp2(theta_2,phi_2,r,theta,phi)
1 Comment
Walter Roberson
on 27 Sep 2020
the part that has to be a mesh is theta_2 and phi_2
Answers (1)
I want to make a structure(eg: r=cos^10(theta)) in the spherical coordinate system and plot the combination of (orginal pattern+rotota 90 pattern)
You could just use hgtransform()
h1=surf(X_patch_1,Y_patch_1,Z_patch_1,'EdgeColor','interp');
t2 = hgtransform('Parent',gca, 'Matrix',makehgtform('xrotate',pi/2));
h2 = copyobj(h1,t2);
Categories
Find more on Vector Fields in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!