How to make animtion of 3D surface plot?

32 ビュー (過去 30 日間)
priya anjali
priya anjali 2020 年 6 月 29 日
コメント済み: priya anjali 2020 年 6 月 29 日
I'm having my code here where I want to put animation. Can we show this animation wrt to any parameter?
  2 件のコメント
Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2020 年 6 月 29 日
To create an animation you will need to plot continuously different plots. Say you want to have 10 or 20 frames in your animation you could do this with a for loop:
for k=1:10
% use your code here, change the variables and surf each time
end
Now, you will need to grab each plot, so after each surf add the following:
drawnow
F(k) = getframe;
The variable F will contain your animation and then you can save as a video like this
v = VideoWriter('video_name'), 'MPEG-4');
open(v);
writeVideo(v,F);
close(v);
Hope this helps. If this does not solve your problem, please let me know. If it does, please accept the answer.
priya anjali
priya anjali 2020 年 6 月 29 日
編集済み: priya anjali 2020 年 6 月 29 日
Thank you, but it's showing some error about the function.

サインインしてコメントする。

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 29 日
編集済み: Ameer Hamza 2020 年 6 月 29 日
See this example using variable 't'. Adapt it according to your requirement
%suface plot;
x=-20:1:20;
y=-20:1:20;
[x,y]=meshgrid(x,y);
c1=0.1576;
A1=0.9706;
A2=0.9572;
A3=0.4854;
A4=2*A3;
T = linspace(0, 1, 100);
fig = figure;
ax = axes();
hold(ax);
view(3);
grid on
colormap jet;
xlabel('\bf{x}','fontsize',18);
ylabel('\bf{y}','fontsize',18);
zlabel('\bf{u (x,y,t)}','fontsize',18);
s = surf(x,y,zeros(size(x)),'Facealpha','1'); % temporary surface to get the handle
v = VideoWriter('test.mp4', 'MPEG-4');
open(v);
for i=1:numel(T)
t=T(i);
b=cos(t);
A=log(b);
s.ZData = c1./((x./(A1+3*t).^1./3+A-(A2+y)./(A1+3*t).^1./3-A4)*(A1+3*t).^1./3);
drawnow;
frame = getframe(fig);
writeVideo(v, frame)
end
close(v);
  5 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 6 月 29 日
You want to add images to pdf file? See export graphics() to save images at few values of 'y'.
priya anjali
priya anjali 2020 年 6 月 29 日
Yes, in pdf file which i generated from latex file. Here i can put a command on .mp4 file to attach. So, is it possible to save it as a vedio ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by