我要加入 登录
声振论坛 返回首页

lihaitao123的个人空间 http://home.vibunion.com/?159990 [收藏] [复制] [分享] [RSS]

日志

西安交大周纪卿老师非线性振动书中的源代码

已有 1276 次阅读2013-7-9 14:26 | 吸引域, 源代码

clc;
clear all
title('胞映射')
xl=-1.025;xu=1.525;yl=-2.535;yu=1.035;
nxc=101;nyc=101;
h1=(xu-xl)./nxc;h2=(yu-yl)./nyc;
nc=nxc.*nyc+1;n=1;
xl1=xl-h1./2.0;yl1=yl-h2./2.0;
for i=1:nyc
    for j=1:nxc
        ij=j+(i-1).*nxc;z1(ij)=j;z2(ij)=i;
    end
end
 z1(nc)=0;z2(nc)=0;
for i=1:nc
    gr(i)=0;
end
for ii=1:nc
    m=0;g=gr(ii);
    if g==0
        gr(ii)=-1;b1=z1(ii);b2=z2(ii);
        c1=b1;c2=b2;v=1;
        while v==1
            m=m+1;
            xc=c1.*h1-h1./2.0;yc=c2.*h2-h2./2.0;
            c1=fix((0.9*(yc+yl)+1.81*(xc+xl).^2-xl)./h1+0.5);
            c2=fix((-0.9*xc-0.9*xl-yl)./h2+0.5);
            if c1>nxc|c1<1|c2>nyc|c2<1;
                c1=0;c2=0;
          else
            end
          e1=c1;e2=c2;ij=c1+(c2-1).*nxc;
          if c1==0
              ij=nc;
          else
          end
          g=gr(ij);
          if g~=0;
              if g==-1;
                  i=0;
                  if b1~=e1|b2~=c2;
                      c1=b1;c2=b2;w=1;
                      while  w==1;
                          i=i+1;xc=c1.*h1-h1./2.0;yc=c2.*h2-h2./2.0;
      c1=fix((0.9*(yc+yl)+1.81*(xc+xl).^2-xl)./h1+0.5);
       c2=fix((-0.9*xc-0.9*xl-yl)./h2+0.5);
       if c1>nxc|c1<1|c2>nyc|c2<1;
           c1=0;c2=0;
       else
       end
       if c1==e1&c2==e2;
           break
       else
       end
             end
                  else
                  end
             if c1==0
                 gg=1;pe=1;
             else
                 n=n+1;pe=m-1;gg=n;
             end
             c1=b1;c2=b2;
             ij=c1+(c2-1).*nxc;
             if c1==0;
                 ij=nc;
             else
             end
             gr(ij)=gg;p(ij)=pe;s(ij)=i;
             if i~=0
                 for j=1:i-1
                     xc=c1.*h1-h1./2.0;    yc=c2.*h2-h2./2.0;
                     c1=fix((0.9*(yc+yl)+1.81*(xc+xl).^2-xl)./h1+0.5);
                    c2=fix((-0.9*xc-0.9*xl-yl)./h2+0.5);
                       if c1>nxc|c1<1|c2>nyc|c2<1;
                    c1=0;c2=0;
                     else
                       end
         ij=c1+(c2-1).*nxc;
            if c1==0|c2==0;
                ij=nc;
            else
            end
            gr(ij)=gg;p(ij)=pe;s(ij)=i-j;
                 end
                 i=1;
             end
             for j=1:m-1
                 xc=c1.*h1-h1./2.0;yc=c2.*h2-h2./2.0;
                 c1=fix((0.9*(yc+yl)+1.81*(xc+xl).^2-xl)./h1+0.5);
       c2=fix((-0.9*xc-0.9*xl-yl)./h2+0.5);
                    if c1>nxc|c1<1|c2>nyc|c2<1;
                    c1=0;c2=0;
                     else
                       end
          ij=c1+(c2-1).*nxc;
             if c1==0;
                 ij=nc;
             else
             end
             gr(ij)=gg;p(ij)=pe;s(ij)=0;   
             end
              else
                  g=gr(ij);pe=p(ij);st=s(ij);
                  c1=b1;c2=b2;ij=c1+(c2-1).*nxc;
                  if c1==0;
                      ij=nc;
                  else
                  end
                      gr(ij)=g;p(ij)=pe;s(ij)=st+m;
                      for j=1:m-1
                          xc=c1.*h1-h1./2.0;yc=c2.*h2-h2./2.0;
                   c1=fix((0.9*(yc+yl)+1.81*(xc+xl).^2-xl)./h1+0.5);
             c2=fix((-0.9*xc-0.9*xl-yl)./h2+0.5);
                    if c1>nxc|c1<1|c2>nyc|c2<1;
                    c1=0;c2=0;
                     else
                    end
                   ij=c1+(c2-1).*nxc;
             if c1==0;
                 ij=nc;
             else
             end  
               gr(ij)=g;p(ij)=pe;s(ij)=st+m-j;
                      end
              end
              break
          else
              gr(ij)=-1;
          end
        end
    else
    end
end
ax=112;ay=46;
for ii=2:n
 for i=1:nc-1
    if gr(i)==ii
        x=z1(i).*h1+xl1;y=z2(i).*h2+yl1;
        xi=x.*ax; yi=y.*ay;
        hold on
        plot(xi,yi,'.k');
        xc=xi./8;yc=yi./8;
    else
    end
end
end

                         
                 

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 我要加入

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

GMT+8, 2024-12-26 00:19 , Processed in 0.049217 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部