温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

matlab怎么实现单个物体运动可视化生成gif

发布时间:2022-01-14 10:10:09 来源:亿速云 阅读:107 作者:iii 栏目:大数据

本篇内容主要讲解“matlab怎么实现单个物体运动可视化生成gif”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“matlab怎么实现单个物体运动可视化生成gif”吧!

function bouncer

   [z0,h] = initialize_bouncer;

   g = 9.8;        

   c = 0.75;       

   delta = 0.005;  

   v0 = 21;        

   k = 0;

   while v0 >= 1

      v = v0;

      z = z0;

      while all(z >= 0)

         set(h,'zdata',z)

         drawnow

         v = v - delta*g;

         z = z + delta*v;

         k = k + 1;

      frame(k)=getframe(gcf); % get the frame

      pause(0.01)

      end

      v0 = c*v0;

   end

   finalize_bouncer

   writegif('test.gif',frame,0.01);

end

%-----------------------------------------------

function [z,h] = initialize_bouncer

   clf

   shg

   set(gcf,'menubar','none','numbertitle','off','name','Bouncer', ...

       'color','white')

   axes('position',[0 0 1 1])

   [x,y,z] = sphere(20);

   z = z + 1;

   h = surf(x,y,z);

   colormap copper

   shading interp

   axis([-12.5 12.5 -12.5 12.5 0 25.0])

   axis square off

   view(90,0)

   uicontrol('string','TOSS','style','pushbutton', ...

      'units','normal','position',[.10 .05 .12 .05], ...

      'background','white','fontweight','normal', ...

      'enable','off','callback','bouncer')

   drawnow

end

%-----------------------------------------------

function finalize_bouncer

   set(findobj('string','TOSS'),'fontweight','bold','enable','on')

到此,相信大家对“matlab怎么实现单个物体运动可视化生成gif”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI