How to use MATLAB to generate a 3D model and import it into PPT

    Hello everyone, here is classmate Chen who was confined at home because of three positive cases in the neighborhood next door. Today's article that has been around for more than two weeks will give a way to import the 3D image drawn by MATLAB into PPT, just like the following.

------------------ CSDN seems to be unable to insert gif, if necessary, you can follow my work number "Haiyanren" to see ------------ -------------------

 

    MATLAB provides us with many tools for drawing three-dimensional images, such as surf, mesh, plot3, etc. We can use the surf function to draw a three-dimensional topographic map that looks good but is useless like the one below.

    Putting such a static image in one's own reports, courseware and other PPTs can add a lot of b-frames. Wouldn't it be taller if it could be rotated? It is of course a way to realize the rotation animation by manual operation or programming and recording the screen in MATLAB, but the animation obtained in this way is not very good-looking.

    We all know that PPT has many excellent animation effects built in. Is there a way to import 3D graphics drawn by MATLAB into PPT? Here's a naive way I figured out.

                               Gongzhong account "Haiyanren" backstage reply "3D" to receive sample code, data and model files

Step 1: Draw the 3D image you want

    Here we use terrain data as an example. If you need code and data, please fetch it yourself in the background.

    After drawing, you can actually record the screen directly to make animations, but to make animations like the three examples above, you need to find a way to import the drawn 3D images into PPT for subsequent operations. The question is how to achieve it?

    Bill McDonald uploaded a function in MathWorks - surf2stl, which can convert the surface data drawn with the surf function into a 3D model in stl format, and the model can be opened in Paint 3D, an artifact that comes with Win10 (Sorry Apple doesn't have one).

(Source: Bill McDonald (2022). surf2stl (https://www.mathworks.com/matlabcentral/fileexchange/4512-surf2stl), MATLAB Central File Exchange. Retrieved 2022/7/26.)

Step 2: Export stl file

    After exporting the cropped elevation data to stl format, import it into Paint 3D, at this time we found that the model has no color. But there is a stupid way to "stick" the model.

Step Three: Make the Stickers

    Draw a plane topographic map with the same latitude and longitude range as the three-dimensional topographic map, and adjust the colormap method.

    Cut off the surrounding blank parts. Here, it is best to whiten the drawing area, coordinate axes, scale marks and other elements when drawing as above for easy cropping (it doesn’t matter if there is stretching).

 

Step 4: Apply stickers to the model

    Add the flat topographic map you just cropped in Sticker-Custom Sticker.

    Drag the square button in the middle and upper part to flatten the 3D model as much as possible (it will be easier to align during the pasting process), and drag the rotation button on the right to 90°.

------------------ CSDN seems to be unable to insert gif, if necessary, you can follow my work number "Haiyanren" to see ------------ -------------------

    Click the added sticker and drag the four corners to match the sticker with the model. After dragging, click any blank area to end. If the sticker result is not satisfactory, you can press ctrl+z to paste it again.

------------------ CSDN seems to be unable to insert gif, if necessary, you can follow my work number "Haiyanren" to see ------------ -------------------

    Drag the right rotation button, then drag the square button in the upper middle to pull the 3D model back to its original shape. You're done.

------------------ CSDN seems to be unable to insert gif, if necessary, you can follow my work number "Haiyanren" to see ------------ -------------------

Step 5: Export the colored model to PPT

    Click the upper left menu, save-3D model, and the format of the saved model file is glb.

    After saving, create a new PPT, toolbar-insert-3D model-this device, and find the file you just saved.

------------------ CSDN seems to be unable to insert gif, if necessary, you can follow my work number "Haiyanren" to see ------------ -------------------

    At this time, the 3D model has the same transparent background as png, and supports a series of animations that come with PPT. This thing is used as a PPT for reports, and it is simply high-end, atmospheric, and high-grade!

------------------ CSDN seems to be unable to insert gif, if necessary, you can follow my work number "Haiyanren" to see ------------ -------------------

    Of course, this process is really cumbersome. If MATLAB draws a good picture and there is a way to import it directly into PPT, it can only be said that I am short-sighted. Welcome to the background to slap me in the face.

                               Gongzhong account "Haiyanren" backstage reply "3D" to receive sample code, data and model files

Guess you like

Origin blog.csdn.net/m0_51143849/article/details/126009570