Representing calculated values on sphere.

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.

답변 (1개)

Star Strider
Star Strider 2017년 1월 7일

0 개 추천

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.

카테고리

제품

질문:

2017년 1월 7일

답변:

2017년 1월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by