Populating array help for Earth grid creation

조회 수: 3 (최근 30일)
Scott Hunter
Scott Hunter 2019년 6월 15일
답변: Scott Hunter 2019년 6월 15일
I want to create an array of 3-coordinate points (azimuth, elevation and R) in the shape of a sphere (to get and Earth grid), but am currently struggling. I've been trying with both sph2cart and just the sphere function but can't figure out how to get my X,Y,Z (or az,el,R) data for each point. Currently I've been trying;
res = 20; %resolution of Earth grid
R = 100;
LDA = -pi:2*pi/res:pi;
PHI = -pi/2:pi/res:pi/2;
for ii = 1:length(LDA)^2
for jj = 1:length(LDA)
for kk = 1:length(PHI)
point(ii,:) = [LDA(jj) PHI(kk) R];
end
end
end
I'm aware this doesn't work because it just overwrites every time the loop number changes, but it helps illustrate that I want my points in an array with 3 collumns for comparing to other points that I'll have later. Is there a better way to do this?

채택된 답변

Scott Hunter
Scott Hunter 2019년 6월 15일
I managed to solve the issue but not sure it was the best way around it. Used 3-D arrays;
res = 20; %resolution of Earth grid
R = 100;
LDA = -pi:2*pi/res:pi;
PHI = -pi/2:pi/res:pi/2;
for ii = 1:length(LDA)
for jj = 1:length(PHI)
point(ii,jj,:) = [LDA(ii) PHI(jj) R];
end
end
If anyone has any better approaches let me know!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Earth and Planetary Science에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by