一、获取代码方式

获取代码方式1:
完整代码已上传我的资源: 【运动学】基于matlab GUI模拟小球自由落体【含Matlab源码 1630期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、部分源代码

function bb()
% BB Bouncing Ball Physics
% BB is a graphical User Interface that creates a simple simulation of a ball bouncing
% off the ground.
%
% Ball Parameters are:
%
% Height from the center of the ball to the ground is 10. This is constant and cannot
% change. Instead, change the other parameters since they're all relative.
%
% Radius: Radius of the ball. It's best to put it between 1 and 9. Any value equal to
% or above 10 will present problems as 10 is the distance from the centre of the ball
% to the ground.
%
% Gravity: Affect the ratio in which the ball gains speed in the negative Y direction.
%
% Initial Yv: Initial velocity in the Y direction. Can be positive, negative, or anything.
%
% Initial Xv: Initial velocity in the X direction. Can be positive, negative, or anything.
%
% Vertical Speed Conservation (%): Affects how much energy (velocity) is retained in the
% Y direction after hitting the ground. A value of 0 to 100 is normal. A value of 0 means
% no energy is retained and the ball comes to a halt after hitting the ground. A value
% of 100 means all energy is retained and the ball will bounce indefinitely. A value of
% over 100 will cause energy to increase after hitting the ground.
%
% Horizontal Speed Conservation (%): Same as Vertical Speed Conservation but in the
% X direction.
%
% Colour: Three element vector ([R G B]) in which the ball appears in. Each
% element should be between or equal 0 and 1.
%
%
% Plotting a path enables you to see the x-y diagram of the ball's movement and gives
% you the ability to pan the axes with the mouse.
%
% To launch the GUI, type bb in the command window with this file in the current
% directory. Alternatively, you can choose Debug -> Run from this editor window, or
% press F5.
%
%figure('units','normalized','position',[.2 .2 .65 .65],'menubar','none','numbertitle','off','color','w','name','Bouncing Ball')
axes('position',[.25 .05 .65 .75])
ed1=uicontrol('style','edit','units','normalized','position',[.025 .895 .1 .05],'backgroundcolor','w','string','1','callback',@init);
uicontrol('style','text','units','normalized','position',[.025 .96 .1 .025],'backgroundcolor','w','string','Radius');
ed2=uicontrol('style','edit','units','normalized','position',[.025 .775 .1 .05],'backgroundcolor','w','string','9.81');
uicontrol('style','text','units','normalized','position',[.025 .84 .1 .025],'backgroundcolor','w','string','Gravity');
ed3=uicontrol('style','edit','units','normalized','position',[.025 .65 .1 .05],'backgroundcolor','w','string','0');
uicontrol('style','text','units','normalized','position',[.025 .72 .1 .025],'backgroundcolor','w','string','Initial Yv');
ed4=uicontrol('style','edit','units','normalized','position',[.025 .535 .1 .05],'backgroundcolor','w','string','500');
uicontrol('style','text','units','normalized','position',[.025 .6 .1 .025],'backgroundcolor','w','string','Initial Xv');
ed5=uicontrol('style','edit','units','normalized','position',[.025 .415 .1 .05],'backgroundcolor','w','string','70');
uicontrol('style','text','units','normalized','position',[.005 .48 .21 .025],'backgroundcolor','w','string',...'Vertical Speed Conservation (%)','horizontalalignment','left');
ed6=uicontrol('style','edit','units','normalized','position',[.025 .295 .1 .05],'backgroundcolor','w','string','50');
uicontrol('style','text','units','normalized','position',[.005 .36 .21 .025],'backgroundcolor','w','string',...'Horizontal Speed Conservation (%)','horizontalalignment','left');
ed7=uicontrol('style','edit','units','normalized','position',[.025 .175 .1 .05],'backgroundcolor','w','string','1 0 0','callback',@init);
uicontrol('style','text','units','normalized','position',[.025 .24 .1 .025],'backgroundcolor','w','string','Colour ([R G B])');
tb=uicontrol('style','togglebutton','string','Start','callback',@go,'units','normalized','position',[.025 .05 .1 .05],...'backgroundcolor','w');
chk=uicontrol('style','checkbox','string','Plot Path','units','normalized','position',[.025 .125 .1 .025],'backgroundcolor','w');init;function [hb,h2,hx,h1,r,t]=init(varargin)r=str2double(get(ed1,'string'));t=linspace(0,2*pi,100);cla resethold oncl=str2num(get(ed7,'string')); %#okh1=fill((5)+r*cos(t),(10)+r*sin(t),cl);axis([0 10 -1 10+r+1])axis equalhx=axis;hL=line(1000.*[hx(1),hx(2)],[0 0]);set(hL,'color','k','linestyle','-','linewidth',3)hL=line(1000.*[hx(1),hx(2)],[10 10]);axis(hx)set(hL,'color','c','linestyle','--')set(h1,'linewidth',2)h2=plot(5,10,'k+');hb=[h1,h2];endfunction go(varargin)set(tb,'value',0)if strcmp(get(tb,'string'),'Start')          set(tb,'string','Stop')         elseset(tb,'string','Start')returnenddt=1;[hb,h2,hx,h1,r,t]=init;a=str2double(get(ed2,'string'))/2000;Yv=str2double(get(ed3,'string'))/2000;Xv=str2double(get(ed4,'string'))/2000;e=str2double(get(ed5,'string'))/100;f=str2double(get(ed6,'string'))/100;while strcmp(get(tb,'string'),'Stop')yc=get(h2,'ydata');if get(chk,'value')plot(get(h2,'xdata'),yc,'k.')pan onendYv=Yv+a*dt;if yc-(Yv+a*dt)*dt<=rYv=Yv+a*dt/(Yv+a*dt)*(yc-r);Yv=-Yv*e;set(h2,'ydata',r)set(h1,'ydata',r+(r)*sin(t))Xv=Xv*f;elsefor k=1:2set(hb(k),'ydata',get(hb(k),'ydata')-Yv*dt)endend

三、运行结果

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.

【运动学】基于matlab GUI模拟小球自由落体【含Matlab源码 1630期】相关推荐

  1. matlab 地形模拟程序,MATLAB模拟小球自由落体运动

    大部分朋友学习MATLAB,需要一个学习示例用来参考,有一个比较经典的题目就是如何利用Matlab模拟小球自由落体运动,这可能会是你的某次课后作业,这个程序的编写过程可以分为三个步骤: 第一部分,设置 ...

  2. 【音乐播放】基于matlab GUI动感音乐播放【含Matlab源码 778期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[音乐播放]基于matlab GUI动感音乐播放[含Matlab源码 778期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  3. 【雷达通信】基于matlab GUI相控阵雷达方向图【含Matlab源码 1048期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[雷达通信]基于matlab GUI相控阵雷达方向图[含Matlab源码 1048期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方 ...

  4. 【数据分析】基于matlab GUI齿轮箱振动数据分析【含Matlab源码 2122期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[数据分析]基于matlab GUI齿轮箱振动数据分析[含Matlab源码 2122期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方 ...

  5. 【光学】基于matlab GUI维达尔之眼计算【含Matlab源码 2545期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI维达尔之眼计算[含Matlab源码 2545期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  6. 【光学】基于matlab GUI双孔干涉【含Matlab源码 2119期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI双孔干涉[含Matlab源码 2119期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...

  7. 【光学】基于matlab GUI双缝干涉和牛顿环【含Matlab源码 2165期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI双缝干涉和牛顿环[含Matlab源码 2165期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...

  8. 【数字信号】基于matlab GUI电话按键识别【含Matlab源码 2382期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[数字信号]基于matlab GUI电话按键识别[含Matlab源码 2382期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...

  9. Matlab GUI/APP 浅谈(附计算器源码)

    Matlab GUI/APP 浅谈(附计算器源码) 今天没有什么段子,也没有心灵鸡汤.毒鸡汤啥的,纯粹聊一聊这些年从有关MATLAB GUI/APP开发中悟出的一点道理,顺便把计算器的源代码给大家. ...

  10. 【课程设计】基于java GUI实现学生个人信息管理系统(源码+论文+ppt+视频)

    源码资料 免费下载 不经常在线,需要源码和资料的留言私信我,主页有联系方式 技术架构 开发语言 主要用的是Java语言中的GUI(图形用户界面)和AWT(抽象窗口工具包)编程. (1) GUI 图形用 ...

最新文章

  1. Scanner对象及其获取数据出现小问题和解决方案
  2. Jenkins 最新版qq邮箱配置实例演示,5步设置保证邮件接收成功!
  3. LabelBinarizer的妙用
  4. android 百度定位开启后fragment 不显示,解决Android百度地图MapView在ViewPager中Fragment切换黑屏问题...
  5. 【渝粤教育】国家开放大学2018年秋季 0505-22T护理学基础 参考试题
  6. java基础——equals及==的区别
  7. AI落地谁最强?AI Top 30+案例评选等你来秀
  8. c语言 已知某系统在通信联络中,数据结构(习题)..doc
  9. Tensorflow官方文档学习理解 (五)-卷积MNIST
  10. 夺命雷公狗---微信开发54----微信js-sdk接口开发(1)之快速入门
  11. 小程序毕设作品之微信小程序点餐系统毕业设计(6)开题答辩PPT
  12. Windows Server AppFabric 安装文档
  13. def demo什么意思python_你知道Python的所有入门级知识吗?,这些,都,会,了
  14. python卸载清理注册表_使用Python操作注册表
  15. animation动画全解
  16. element中file-upload组件的提示‘按delete键可删除’,怎么去掉
  17. KEIL工程文件打不开
  18. 邮箱如何群发邮件,公司邮件群发教程
  19. IT行业大致工作方向
  20. 安装apache遇到You don’t have permission to access this resource. 原因与解决方法

热门文章

  1. 算法交流:分享我的一个算法,实现项目需求
  2. Ant-编译构建(2)-第3方jar包引入、log4j2
  3. 云存储20181101-16讲
  4. Axure RP 9 Beta 开放下载(更新激活密钥和汉化包)
  5. 802.1q VLAN
  6. 1.多线程和单线程简单比较
  7. 【BZOJ4557】[JLoi2016]侦察守卫 树形DP
  8. Qt QT_BEGIN_NAMESPACE
  9. 闽江学院2015-2016学年下学期《软件测试》课程-第四次博客作业
  10. 统计各班参加补考的人数