声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1289|回复: 2

[线性振动] 两自由度碰振程序不知道哪出问题了?

[复制链接]
发表于 2011-12-3 22:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
clc
clear all
global delta a b c d  m r w f
delta=0;
m=0.5;
r=0.8;
w=4.1;
f=10;
w2=1;
delta=0;
a=(m-r)/(m+1);
b=(1-r)/(m+1);
c=m*(1+r)/(m+1);
d=(1-m*r)/m+1;
tstart=0;
tfinal=10;
  u0=[1,-1,-1,1];
tout=tstart;
  uout=u0.';
options=odeset('Event','on');
for i=1:15
     [t,u,event]=ode45(@pengzhen,[tstart,0.03,tfinal],u0,options);
     tout=[tout;t(2:end)];
     uout=[uout;u(2:end,:)];
     u0(1)=u(end,1);
     u0(2)=u(end,2);
       v10=u(end,3);
       v20=u(end,4);
     u0(3)=a*v10+b*v20;
     u0(4)=c*v10+d*v20;
     tstart=t(end);
end
figure
ylalel('位移');xlabel('时间');
  subplot(2,1,1)
  plot(tout,uout(:,1))
  subplot(2,1,2)
  plot(tout,uout(:,2))
回复
分享到:

使用道具 举报

 楼主| 发表于 2011-12-3 22:38 | 显示全部楼层
回复 1 # lihaitao123 的帖子

function vararout=pengzhen(t,u,flag) %%判断何时运用时间
switch flag
    case''
        varargout1=f(t,u);
    case'events'
        [varargout1:3]=events(t,u);
    otherwise
        error{'Unkown flag ' ''flag''  '.'};
end
 楼主| 发表于 2011-12-3 22:40 | 显示全部楼层
回复 2 # lihaitao123 的帖子

function dy=f(t,u)    %%子函数
global a b c d  m r w f
m=0.5;
r=0.8;
w=4.1;
f=10;
w2=1;

du=[u(3);
    u(4);
   -u(1)+cos(w.*t);
   -w2^2*u(2)+f*cos(w.*t)];

function[value,isterminaldirection]=events(t,u)
Q=u(1)-u(2);value=Q;
isterminal=1;
direction=-1
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-20 13:14 , Processed in 0.115050 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表