Ellipse around the data in MATLAB

后端 未结 3 583
太阳男子
太阳男子 2020-12-08 16:56

I would like to reproduce the following figure in MATLAB:

\"exampleee.png\"

There are two classes of po

3条回答
  •  -上瘾入骨i
    2020-12-08 17:28

    I'll assume there is only one set of points given in a single matrix, e.g.

    B = A(1:10,2:3);
    

    you can reproduce this procedure for each data set.

    1. Compute the center of the ellipsoid, which is the mean of the points. Matlab function: mean
    2. Center your data. Matlab function bsxfun
    3. Compute the principal axis of the ellipsoid and their respective magnitude. Matlab function: eig

    The successive steps are illustrated below:

    Center = mean(B,1);
    Centered_data = bsxfun(@minus,B,Center);
    [AX,MAG] = eig(Centered_data' * Centered_data);
    

    The columns of AX contain the vectors describing the principal axis of the ellipsoid while the diagonal of MAG contains information on their magnitude. To plot the ellipsoid, scale each principal axis with the square root of its magnitude.

    Hope this helps.

    A.

提交回复
热议问题