How to plot a triangular pyramid in matlab with 4 vertex in matlab

140 Views Asked by At

After thousands trials, Im not able to 3d plot a pyramid using 4 vertex using surf.

This is the best approach that I have found in matlab forum, but in my case I need to input those values and not be fixed as it is in the link.

[https://es.mathworks.com/matlabcentral/answers/556651-how-to-plot-three-dimensional-triangular-based-pyramid][1]

Please, can someone help me?

this is my best try, or I think so! Im doing it in appdesigner

            P1=[app.UITable.Data(1,1),app.UITable.Data(1,2),app.UITable.Data(1,3)];
        P2=[app.UITable.Data(2,1),app.UITable.Data(2,2),app.UITable.Data(2,3)];
        P3=[app.UITable.Data(3,1),app.UITable.Data(3,2),app.UITable.Data(3,3)];
        P4=[app.UITable.Data(4,1),app.UITable.Data(4,2),app.UITable.Data(4,3)];

        if isequal(P1,P2) || isequal(P1,P3) || isequal(P1,P4) || isequal(P2,P3) ||  isequal(P2,P4) || isequal(P3,P4)

            errordlg('vertices iguales')
        else

            vertex=[P1; P2 ;P3 ;P4];
            face= [1 2 3 nan; 2 3 4 nan; 1 2 4 nan; 1 3 4 nan];
            patch('Faces',face,'Vertices',vertex,'Facecolor',[0.8 0.8 1]);
            view(3);
            grid on
            
        end
0

There are 0 best solutions below