声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

声振论坛 展示 振动理论 非线性振动 查看内容

分岔的基本概念及matlab程序实现

2015-10-19 04:33| 发布者: aspen| 查看: 1950| 评论: 0|原作者: 无水1324|来自: 声振论坛

摘要: 如题,最基本的分岔概念如:saddle-node;transcritical;supercritical pitchfork;subcritical pitchfork等,如果你不是很了解,可以学习一下下面的程序。 %% Animation for a Saddle Node bifurcation % ...
如题,最基本的分岔概念如:saddle-node;transcritical;supercritical pitchfork;subcritical pitchfork等,如果你不是很了解,可以学习一下下面的程序。



  1. %% Animation for a Saddle Node bifurcation
  2. % Range of x
  3.      xmin = -4;
  4.      xmax = 4;
  5.      x = xmin:0.1:xmax
  6. % Some auxiliary variable to plot x-axis
  7.      ax = (0.0).*x;
  8. % Range of r
  9.      rmin = -4
  10.      rmax = 4
  11. % number of frames in the movie
  12.      imax = 21
  13. % Rage of dx/dt (here y=dx/dt)
  14.      ymin = rmin ;
  15.      ymax = rmax + xmax.^2;
  16. % Some auxiliary variables to plot the y-axis
  17.      ky = ymin:0.1:ymax
  18.      ay = (0.0).*ky
  19. %% Start of the loop for acquisition of the movie frames
  20. for i = 1:imax
  21. %calculate r value
  22.      r = rmin + (i-1)*(rmax-rmin)/(imax-1)
  23. %create string for labelling r
  24.      strr = num2str(r);
  25.      strt = ['r=' strr];
  26. %calculate dxdt
  27.      y = r + x.^2
  28. %plot x-axis
  29.      plot(x,ax,'--');
  30. % determine range of plot
  31.      axis([xmin xmax ymin ymax])
  32.      hold on
  33. %plot y-axis
  34.      plot(ay,ky,'--')
  35. %plot f(x)
  36.      plot(x,y,'r');
  37. %plot fixed points
  38. if (r < 0)
  39.      plot(-(-r).^(0.5),0,'o','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  40.      plot((-r).^(0.5),0,'o','MarkerSize',10,'MarkerEdgeColor','k');
  41. end
  42. if(r == 0.0)
  43.      plot((-r).^(0.5),0,'*','MarkerSize',10,'MarkerEdgeColor','k');
  44. end
  45. %plot flow direction
  46. if(r < 0)
  47.      plot(-3,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  48.      plot(0,0,'<','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  49. plot(3,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  50. end
  51. if(r == 0)
  52.      plot(-3,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');     
  53. plot(3,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  54. end
  55. if(r > 0)
  56.      plot(-3,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');     plot(0,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  57. plot(3,0,'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','k');
  58. end
  59. %plot labels
  60.      xlabel('x','FontSize',20)
  61.      ylabel('dx/dt','FontSize',20)
  62.      text(-3,15,'dx/dt = r + x^2','Color','r','FontSize',20)
  63.      text(1,15,strt,'FontSize',20)
  64.      title('Saddle Node Bifurcation','FontSize',20)
  65. %get movie frame
  66.      h = gcf;
  67.      M(i) = getframe(h,[5 5 480 380]);
  68.      hold off
  69. % end of loop
  70. end
  71. %play and save movie
  72.      movie(M);
  73.      movie2avi(M,'SaddleNode','fps',1);

复制代码

最新评论

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

GMT+8, 2024-4-25 19:22 , Processed in 0.058296 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部