二级倒立摆仿真源码程序 - Simulink建模仿真 - 谷速源码
下载频道> 资源分类> matlab源码> Simulink建模仿真> 二级倒立摆仿真源码程序

标题:二级倒立摆仿真源码程序
分享到:

所属分类: Simulink建模仿真 资源类型:程序源码 文件大小: 1.46 KB 上传时间: 2016-01-24 22:17:35 下载次数: 9 资源积分:1分 提 供 者: matlab源码 二级倒立摆仿真源码程序
内容:
二级倒立摆仿真源码程序,程序员在编程的过程中可以参考学习使用,希望对IT程序员有用,此源码程序简单易懂、方便阅读,有很好的学习价值!
部分代码如下:
%--------------------------------------------------------------------------
%-------------- Double Pendulum--------------------------------------------
%--------------------------------------------------------------------------
 
clc
close all
clear all
 
%---------Parameters------------------------------------------------------
 
l1=1; l2=2 ; m1=2 ; m2=1; g=9.8;
 
%---------initial condition-----------------------------------------------
 
tspan=50;
theta1=1.6;
theta1_prime=0;
theta2=2.2;
theta2_prime=0;
 
y0=[theta1 theta1_prime theta2 theta2_prime];
[t,y]=ode45(@pend, [0 ,tspan],[ 2.5 0 1 0]);
 
 
%---position of mass 1 and mass 2----------------------------------------
 
x1=l1*sin(y(:,1));
y1=-l1*cos(y(:,1));
x2=l1*sin(y(:,1))+l2*sin(y(:,3));
y2=-l1*cos(y(:,1))-l2*cos(y(:,3));
 
%------visualizing the result---------------------------------------------
 
   figure(1)
   plot(x1,y1,'linewidth',2)
   hold on
   plot(x2,y2,'r','linewidth',2)
   h=gca; 
   get(h,'fontSize') 
   set(h,'fontSize',14)
   xlabel('X','fontSize',14);
   ylabel('Y','fontSize',14);
   title('Chaotic Double Pendulum','fontsize',14)
   fh = figure(1);
   set(fh, 'color', 'white'); 
   
   figure(2)
   plot(y(:,1),'linewidth',2)
   hold on
   plot(y(:,3),'r','linewidth',2)
   h=gca; 
   get(h,'fontSize') 
   set(h,'fontSize',14)
   legend('\theta_1','\theta_2')
   xlabel('time','fontSize',14);
   ylabel('theta','fontSize',14);
   title('\theta_1(t=0)=2.5 and \theta_2(t=0)=1.0','fontsize',14)
   fh = figure(2);
   set(fh, 'color', 'white'); 
   
   
   %----movie of double pendulum--------------------------------------
   
   figure(3)
   Ncount=0;
   fram=0;
   
     for i=1:length(y)
         Ncount=Ncount+1;
         fram=fram+1;
         plot(0, 0,'.','markersize',20);
         hold on
         plot(x1(i),y1(i),'.','markersize',20);
         plot(x2(i),y2(i),'.','markersize',20);
         hold off
         line([0 x1(i)], [0 y1(i)],'Linewidth',2);
         axis([-(l1+l2) l1+l2 -(l1+l2) l1+l2]);
         line([x1(i) x2(i)], [y1(i) y2(i)],'linewidth',2);
         h=gca; 
         get(h,'fontSize') 
         set(h,'fontSize',12)
         xlabel('X','fontSize',12);
         ylabel('Y','fontSize',12);
         title('Chaotic Motion','fontsize',14)
         fh = figure(3);
         set(fh, 'color', 'white'); 
         F=getframe;
         end
 
      movie(F,fram,20)
      
 %-----------------------------------------------------------------------     

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

关键词: 源码 程序

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved