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
2017년 1월 7일
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.
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!