Populating array help for Earth grid creation

2 次查看(过去 30 天)
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