Representing calculated values on sphere.
Show older comments
Hi, I couldn't find a solution to my problem anywhere. I want to show how acceleration of gravity changes based on latitude. Code:
a = 6378137;
b = 6356752.3141;
r = (a*a*b)^(1/3);
omega = 7292115*10^(-11);
GM = 3986005*10^8;
for fi = 1:360
g = GM/(r*r)-omega*omega*r*cosd(fi)*cosd(fi)
end
gEquator = GM/(r^2)-omega^2*r*cosd(180)*cosd(180);
gPole = GM/(r^2)-omega^2*r*cosd(360)*cosd(360);
for zeta = 1:360
gElipsoidy = (a*gRownik*cosd(zeta)*cosd(zeta)+b*gBiegun*sind(zeta)*sind(zeta))/((a^2*cosd(zeta)*cosd(zeta)+b^2*sind(zeta)*sind(zeta))^(1/2))
end
I want the gElipsoidy values to be represented here.
Answers (1)
Star Strider
on 7 Jan 2017
It is straightforwasrd to vectorise your functions and avoid the loops (see Array vs. Matrix Operations for details), then plot them:
a = 6378137;
b = 6356752.3141;
r = (a*a*b)^(1/3);
omega = 7292115E-11;
GM = 3986005E+8;
fi = 1:360;
g = GM/(r*r)-omega*omega*r*cosd(fi).*cosd(fi);
gEquator = GM/(r^2)-omega^2*r*cosd(180).*cosd(180);
gPole = GM/(r^2)-omega^2*r*cosd(360).*cosd(360);
gRownik = 3; % Substitute Missing Value
gBiegun = 5; % Substitute Missing Value
zeta = 1:360;
gElipsoidy = (a*gRownik*cosd(zeta).*cosd(zeta)+b*gBiegun.*sind(zeta).*sind(zeta))./((a^2*cosd(zeta).*cosd(zeta)+b^2*sind(zeta).*sind(zeta)).^(1/2));
figure(1)
plot(zeta, gElipsoidy)
grid
xlabel('Latitude')
ylabel('gElipsoidy')
title('Variation of Gravitational Acceleration as a Function of Latitude')
I have no idea what ‘gRownik’ and ‘gBiegun’ are, so I assumed they are scalars and created values for them to test my vectorised code. If they are vectors, you will have to use the ndgrid function with them and with ‘zeta’. Plotting ‘gElipsoidy’ in that instance could be difficult.
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!