MATLAB: I have prepared 3 D plot for 300 random number with specified std deviation and mean . the question is that how can i draw those points over earth ellipsoid

earth ellipsoid

i need to plot 300 random points on earth ellipsoid with semi-major axis = 638m, semi-minor axis = 566.3142m , and center (X0, Y0, Z0) = (0,0,0).

Best Answer

a=638; % horizontal radius
b=566.3142; % vertical radius
x0=0; % x0,y0 ellipse centre coordinates
y0=0;
t=-pi:0.01:pi;
x=x0+a*cos(t);
y=y0+b*sin(t);
N = 1000 ;
rx = (max(x)-min(x)).*rand(N,1) + min(x);
ry = (max(y)-min(y)).*rand(N,1) + min(y);
idx = inpolygon(rx,ry,x,y) ;
figure
hold on
plot(x,y)
plot(rx(idx==1),ry(idx==1),'.r')
plot(rx(idx==0),ry(idx==0),'.b')