Home>Article> Use matlab to draw a beating heart

Use matlab to draw a beating heart

王林
王林 Original
2019-10-31 09:48:46 23739browse

Use matlab to draw a beating heart

1. Open the MATLAB software, as shown in the figure:

Use matlab to draw a beating heart

2. Create a new script and copy the following program into the script . As shown in the picture:

clc,clear; figure('Color','y') while 1 for i=-5:0.2:5 f=@(xx,yy,zz) xx.^2.*zz.^3+9*yy.^2.*zz.^3/80-(xx.^2+9*yy.^2/4+zz.^2-1).^3;%心形曲面函数 [xx,yy,zz]=meshgrid(-1.5:0.1:1.5);%画图范围 vv=f(xx,yy,zz); h=patch(isosurface(xx,yy,zz,vv,0)); isonormals(xx,yy,zz,vv,h) set(h,'FaceColor','r','EdgeColor','none'); lighting gouraud view(40*i,20) drawnow axis equal off grid off pause(0.01) end end

3. Click Run to get a three-dimensional dynamic "heartbeat" that you can't imagine. It can be moved. Try it yourself. Programming can exercise your logical thinking ability and Spatial imagination ability, so I hope everyone can learn more knowledge through this small program, as shown in the picture:

Use matlab to draw a beating heart

The above is the detailed content of Use matlab to draw a beating heart. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Unable to initialize steam Next article:Unable to initialize steam