Traditional Culture Encyclopedia - Weather inquiry - How to draw dynamic diagram with matlab?
How to draw dynamic diagram with matlab?
x =-8:0.5:8;
[XX,YY]= mesh grid(x);
r=sqrt(XX。 ^2+YY.^2)+eps;
Z=sin(r)。 /r;
surf(Z);
Generate static surf diagram, and generate XX and YY with meshgrid.
2. Enter theAxes = axis below.
As you can see on the right, axes = [0 0,40,0,40, -0.5, 1], which is generated by the surf function. Because surf(XX, YY, z) is not used in the above picture, the coordinate range is different, but whatever the coordinate range is, it is first taken out and put in a variable for later use.
3、mat = movie in(20); Save the fmat as a movie in the structure, where 20 means that the animation has 20 frames.
4. Enter:
For j =1:20;
surf(sin(2*pi*j/20)*Z,Z)
axis
fmat(:,j)= get frame;
end
Here is to draw the image of each frame separately. Here our surf is drawn into 20 parts, and the coordinate axes are unified into the previously saved coordinate axes, and the structure of moviein fmat is taken as getframe, as shown in the figure.
5. Movies (fmat,10); That is, the animation is played 10 times.
6. The complete code is as follows:
x =-8:0.5:8;
[XX,YY]= mesh grid(x);
r=sqrt(XX。 ^2+YY.^2)+eps;
Z=sin(r)。 /r;
surf(Z);
Axis = axis;
fmat = movie in(20);
For j =1:20;
surf(sin(2*pi*j/20)*Z,Z)
axis
fmat(:,j)= get frame;
end
Movie (fmat, 10)
Complete the renderings.
- Previous article:Hong Kong dramas wear summer temperament tops.
- Next article:Sanya travel recommendation, urgent!
- Related articles
- The Qing Dynasty sent people to Ningguta to be armored slaves. What is the status of armor?
- Why doesn't iphone6 have a weather forecast for Kunshan?
- Why did Diaz's expedition fleet come back in three days?
- What is the custom of Spring Festival in South China? Will there be a cold wave in southern Spring Festival travel rush in 2023?
- Write a composition in Pingyi
- Very practical autumn and winter wearing skills, what problems need to be paid attention to?
- What will the weather be like in Lianzhou tomorrow?
- What can't I do with contact lenses? Not in a high temperature environment?
- Climatic characteristics of three northeastern provinces
- Chengdu only has more than 200 sunny days from 10. Why are there so few sunny days in Chengdu?