MATLAB: How can I center the data dataplotting I would like to draw an ellipse, and then center my data points on these ellipses. Best Answer data = rand(100,2) ;plot(data(:,1),data(:,2),'.r') ;%%draw ellipse x = data(:,1) ; y = data(:,2) ;x0 = min(x) ; x1 = max(x) ;y0 = min(y) ; y1 = max(y) ;a=abs(x1-x0) ; % horizontal radiusb=abs(y1-y0); % vertical radius% x0,y0 ellipse centre coordinatesx0=mean(x); y0=mean(y);t=-pi:0.01:pi;xe=x0+a*cos(t);ye=y0+b*sin(t);hold onplot(xe,ye,'b') Related SolutionsMATLAB: How can I rotate the ellipses based on the orientation angle of (x_i,y_i) a=5; % horizontal radiusb=10; % vertical radiusx0=0; % x0,y0 ellipse centre coordinatesy0=0;t=-pi:0.01:pi;x=x0+a*cos(t);y=y0+b*sin(t);plot(x,y)hold on%%Rotate the ellipse by 90 degrees th = pi/2 ;R = [cos(th) -sin(th) ; sin(th) cos(th)] ;% Rotate all the points P = zeros(2,length(x)) ;for i =1:length(x) P(:,i) = R*[x(i) ;y(i)] ;endxr = P(1,:) ; yr = P(2,:) ;plot(xr,yr,'r') 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 a=638; % horizontal radiusb=566.3142; % vertical radiusx0=0; % x0,y0 ellipse centre coordinatesy0=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) ;figurehold onplot(x,y)plot(rx(idx==1),ry(idx==1),'.r')plot(rx(idx==0),ry(idx==0),'.b') Related QuestionHow to draw a circle in a log-log plotPlot ellipsoids with an azimuth angleHow to find coordinates of points that are placed on a line with specific distance from first point of the line
Best Answer