MATLAB: Lines of longitude. How to merge points

lines of longitude

Welcome, At first I apologize for my English level.
I made a script:
fi2=input('Enter latitude (initial value:interval:final value for example. 0:20:90):');
lambda2=input('Enter longitude (initial value:interval:final value for example. -180:20:180):');
R=6378;
fi_s2=input('Enter fi s:');
fi_s=deg2rad(fi_s2);
fi=deg2rad(fi2);
lambda=deg2rad(lambda2);
ro=[R*sin(fi_s)*cot(fi)];
c=[cos(lambda)];
C=ro'*c;
Ct=C';
round(x=Ct( : ));
q=[sin(lambda)];
Q=ro'*q;
Qt=Q';
round(y=Qt( : ));
disp('X,Y coordinates:')
xy=round([x,y])
plot(x,y,'-x'),
xlabel('Coordinate "y"')
ylabel('Coordinate "x"')
title('Cartographic grid ')
grid on
As a result, I got this drawing:
But I need something like that:
The data I used to get the grid (first screen):
How to conect points to get lines of longitude (meridians)? At this moment I have only parallels.
Nobody in Poland can't help my. I hope you know the answer 😉
Thanks for your help.

Best Answer

Assuming this is a first step in mapping something a bit more complicated, I'd suggest using an existing mapping toolbox rather than trying to calculate all the projections from scratch. If you have the Mapping Toolbox available in your license, you can use that. Alternatively, there's the popular m_map toolbox.
ax(1) = subplot(1,2,1);
h = axesm('ortho', ...
'origin', [90 0 0], ...
'grid', 'on', ...
'glinestyle', '-', ...
'meridianlabel', 'on', ...
'parallellabel', 'on', ...
'mlinelocation', 20, ...
'plinelocation', 20, ...
'mlabelparallel', 18, ...
'maplatlimit', [19 90], ...
'fontsize', 8);
set(h, 'visible', 'off');
ax(2) = subplot(1,2,2);
m_proj('ortho', 'lat', 90, 'long', 0);
m_grid('linestyle','-', ...
'ytick',20:20:80, ...
'xtick', -180:20:360, ...
'fontsize', 8);
Related Question