⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 代码汇总.m

📁 一个小小的c语言编程
💻 M
📖 第 1 页 / 共 5 页
字号:
function code

function main
global X1 X2 X3 t X0 Y0 Z0 t0 tf r sigma b time  error %全局变量必须这样定义
global h_menu1_sub1_str_sigma h_menu1_sub1_str_b h_menu1_sub1_str_r
global h_menu1_sub1_text_sigma h_menu1_sub1_text_b h_menu1_sub1_text_r
global h_menu1_sub1_text_bifucationz1 h_menu1_sub1_text_bifucationz2
global h_menu1_sub2_str_sigma h_menu1_sub2_str_b h_menu1_sub2_str_r
global h_menu1_sub2_text_sigma h_menu1_sub2_text_b h_menu1_sub2_text_r
global h_menu1_sub2_text_bifucationx1 h_menu1_sub2_text_bifucationx2  
global h_menu1_sub3_str_sigma h_menu1_sub3_str_b h_menu1_sub3_str_r
global h_menu1_sub3_text_sigma h_menu1_sub3_text_b h_menu1_sub3_text_r
global h_menu2_sub1_radio_1 h_menu2_sub1_radio_2 h_menu2_sub1_radio_3
global h_menu2_sub1_text_bifucationz1 h_menu2_sub1_text_bifucationz2
global h_menu2_sub2_text_bifucationx1 h_menu2_sub2_text_bifucationx2 
global h_menu2_sub2_radio_1 h_menu2_sub2_radio_2 h_menu2_sub2_radio_3
global h_menu2_sub3_radio
global h_my_menu3_sub1_text_xyz_t h_my_menu3_sub1_text_xyz_z h_my_menu3_sub1_text_xyz_x h_my_menu3_sub1_text_xyz_y
global d1 d2 e1 e2
global h_my_menu3_sub2_text_xyz_t h_my_menu3_sub2_text_xyz_z h_my_menu3_sub2_text_xyz_x h_my_menu3_sub2_text_xyz_y
global f1 f2 g1 g2
global htext_input_sigma htext_input_b htext_input_r htext_input_speed str_set_speed 
global rotate_angle rotate_repeat rotate_zhen
global htext_input_angle htext_input_zhen htext_input_repeat 
global str_angle str_zhen  str_repeat 
clf reset
set(gcf,'menubar','none')

h_menu1=uimenu(gcf,'label','投影平面分析');
h_menu2=uimenu(gcf,'label','CPP法');
h_menu3=uimenu(gcf,'label','旋转观察');
h_menu4=uimenu(gcf,'label','图像设置');
h_menu5=uimenu(gcf,'label','参数设置','callback','set_parameter');
h_menu6=uimenu(gcf,'label','退出','callback','quit');

h_menu1_sub1=uimenu(h_menu1,'label','X-Yspace','callback','my_menu1_sub1');
h_menu1_sub2=uimenu(h_menu1,'label','Y-Zspace','callback','my_menu1_sub2');
h_menu1_sub3=uimenu(h_menu1,'label','X-Zspace','callback','my_menu1_sub3');
h_menu1_sub4=uimenu(h_menu1,'label','LyapunovX','callback','Lyapunov(X1)','separator','on');
h_menu1_sub5=uimenu(h_menu1,'label','LyapunovY','callback','Lyapunov(X2)');
h_menu1_sub6=uimenu(h_menu1,'label','LyapunovZ','callback','Lyapunov(X3)');

h_menu2_sub1=uimenu(h_menu2,'label','CPP法X-Yspace','callback','my_menu2_sub1');
h_menu2_sub2=uimenu(h_menu2,'label','CPP法Y-Zspace','callback','my_menu2_sub2');
h_menu2_sub3=uimenu(h_menu2,'label','CPP法X-Zspace','callback','my_menu2_sub3');
h_menu2_sub4=uimenu(h_menu2,'label','CPP法奇点Z(t)处','callback','my_menu2_sub4','separator','on');
h_menu2_sub5=uimenu(h_menu2,'label','CPP法奇点X(t)处','callback','my_menu2_sub5');

h_menu3_sub1=uimenu(h_menu3,'label','Roll X','callback','donghua_x');
h_menu3_sub2=uimenu(h_menu3,'label','Roll Y','callback','donghua_y');
h_menu3_sub3=uimenu(h_menu3,'label','Roll Z','callback','donghua_z');

h_menu4_sub1=uimenu(h_menu4,'label','Blackground_figure');
h_menu4_sub1_sub1=uimenu(h_menu4_sub1,'label','White','callback','set(gcf,''Color'',''White'')');
h_menu4_sub1_sub2=uimenu(h_menu4_sub1,'label','Black','callback','set(gcf,''Color'',''Black'')');
h_menu4_sub1_sub3=uimenu(h_menu4_sub1,'label','Red','callback','set(gcf,''Color'',''Red'')');
h_menu4_sub1_sub4=uimenu(h_menu4_sub1,'label','Blue','callback','set(gcf,''Color'',''Blue'')');
h_menu4_sub1_sub5=uimenu(h_menu4_sub1,'label','Yellow','callback','set(gcf,''Color'',''Yellow'')');
h_menu4_sub1_sub6=uimenu(h_menu4_sub1,'label','Magenta','callback','set(gcf,''Color'',''Magenta'')');
h_menu4_sub1_sub7=uimenu(h_menu4_sub1,'label','Cyan','callback','set(gcf,''Color'',''Cyan'')');
h_menu4_sub1_sub8=uimenu(h_menu4_sub1,'label','Reset','callback','set(gcf,''Color'',[0.8 0.8 0.8])');

h_menu4_sub2=uimenu(h_menu4,'label','Blackground_axis');
h_menu4_sub2_sub1=uimenu(h_menu4_sub2,'label','White','callback','set(gca,''Color'',''white'')');
h_menu4_sub2_sub2=uimenu(h_menu4_sub2,'label','Black','callback','set(gca,''Color'',''black'')');
h_menu4_sub2_sub3=uimenu(h_menu4_sub2,'label','Red','callback','set(gca,''Color'',''Red'')');
h_menu4_sub2_sub4=uimenu(h_menu4_sub2,'label','Blue','callback','set(gca,''Color'',''Blue'')');
h_menu4_sub2_sub5=uimenu(h_menu4_sub2,'label','Yellow','callback','set(gca,''Color'',''Yellow'')');
h_menu4_sub2_sub6=uimenu(h_menu4_sub2,'label','Magenta','callback','set(gca,''Color'',''Magenta'')');
h_menu4_sub2_sub7=uimenu(h_menu4_sub2,'label','Cyan','callback','set(gca,''Color'',''Cyan'')');
h_menu4_sub2_sub8=uimenu(h_menu4_sub2,'label','Reset','callback','set(gca,''Color'',[1 1 1])');
h_menu4_sub3=uimenu(h_menu4,'label','旋转观察设置','callback','set_picture','separator','on');

set(gcf,'unit','normalized','position',[0.002,0.082,1,0.85])
set(gcf,'defaultuicontrolunits','normalized')
h_axes=axes('position',[0.03,0.15,0.7,0.8]);
set(gcf,'defaultuicontrolfontsize',14)
set(gcf,'defaultuicontrolfontname','隶书')
set(gcf,'defaultuicontrolhorizontal','left')

cm=uicontextmenu;
uimenu(cm,'label','Black','callback','set(gca,''Color'',''black'')');
uimenu(cm,'label','Red','callback','set(gca,''Color'',''Red'')');
uimenu(cm,'label','Reset','callback','set(gca,''Color'',[1 1 1])');
set(h_axes,'uicontextmenu',cm)

str='基于Matlab6.5的Lorenz系统性态分析_主界面';
set(gcf,'name',str,'numbertitle','off')
set(h_axes,'xlim',[-20,20],'ylim',[-30,30],'zlim',[0,50])
str_speed='延时时间=';str_sigma='sigma=';str_b='b=';str_r='r=';
str_angle='旋转角度/次=';str_zhen='桢/秒=';str_repeat='重复次数=';

h_text_1=uicontrol(gcf,'style','text',...
   'unit','normalized','position',[0.77,0.89,0.21,0.03],...
   'horizontal','left','string',{'输入初值x0,y0,z0'});
hedit_x=uicontrol(gcf,'style','edit',...	        %初值变量x0,y0,z0
   'position',[0.77,0.85,0.07,0.03],...
   'callback',[...			
   'X0=str2num(get(gcbo,''string''));',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
hedit_y=uicontrol(gcf,'style','edit',...	
   'position',[0.84,0.85,0.07,0.03],...
   'callback',[...			
   'Y0=str2num(get(gcbo,''string''));',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
hedit_z=uicontrol(gcf,'style','edit',...	
   'position',[0.91,0.85,0.07,0.03],...
   'callback',[...			
   'Z0=str2num(get(gcbo,''string''));',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
h_text_2=uicontrol(gcf,'style','text',...
   'unit','normalized','position',[0.77,0.81,0.21,0.03],...
   'horizontal','left','string',{'输入运行时间t0,tf'});
hedit_t0=uicontrol(gcf,'style','edit',...	          %初值变量t0,tf
   'position',[0.77,0.77,0.05,0.03],...
   'callback',[...			
   't0=str2num(get(gcbo,''string''));',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
hedit_tf=uicontrol(gcf,'style','edit',...	
   'position',[0.85,0.77,0.05,0.03],...
   'callback',[...			
   'tf=str2num(get(gcbo,''string''));',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
htext_speed=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.73,0.21,0.03],...
   'string',['选择延时时间',sprintf('%1.4g\',0)]);
hslider_speed=uicontrol(gcf,'style','slider',...
   'position',[0.77,0.69,0.21,0.03],...
   'max',4,'min',0,...		
   'sliderstep',[0.01,0.05],...
   'Value',0);	

htext_3=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.65,0.21,0.03],...
   'string',{'以下为参数设置'});
htext_sigma=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.61,0.21,0.03],...
   'string',['sigma=',sprintf('%1.4g\',10)]);
hslider_sigma=uicontrol(gcf,'style','slider',...
   'position',[0.77,0.57,0.21,0.03],...
   'max',20,'min',5,...		
   'sliderstep',[0.01,0.05],...
   'Value',10);	
htext_b=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.53,0.21,0.03],...
   'string',['b=',sprintf('%1.4g\',8/3)]);
hslider_b=uicontrol(gcf,'style','slider',...
   'position',[0.77,0.49,0.21,0.03],...
   'max',20,'min',2,...		
   'sliderstep',[0.01,0.05],...
   'Value',8/3);
htext_r=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.45,0.21,0.03],...
   'string',['r=',sprintf('%1.10f\',28)]);
hslider_r=uicontrol(gcf,'style','slider',...
   'position',[0.77,0.41,0.21,0.03],...
   'max',40,'min',0,...		
   'sliderstep',[0.001,0.001],...
   'Value',28.04);
htext_input_r=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.15,0.03,0.03],...
   'string','r=');
hedit_r=uicontrol(gcf,'style','edit',...	          
   'position',[0.80,0.15,0.15,0.03],...
   'callback',[...			
   'r=str2num(get(gcbo,''string''));',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);

htext_4=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.37,0.21,0.03],...
   'string',{'以下为坐标显示'});
htext_xyz_t=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.34,0.21,0.03],...
   'string',['t=',sprintf('%2.8f\',0)]);
htext_xyz_x=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.30,0.21,0.03],...
   'string',['x=',sprintf('%2.8f\',0)]);
htext_xyz_y=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.26,0.21,0.03],...
   'string',['y=',sprintf('%2.8f\',0)]);
htext_xyz_z=uicontrol(gcf,'style','text',...	
   'position',[0.77,0.22,0.21,0.03],...
   'string',['z=',sprintf('%2.8f\',0)]);

set(hslider_speed,'callback',[...			
   'time=get(gcbo,''value'');',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)'])
set(hslider_sigma,'callback',[...			
   'sigma=get(gcbo,''value'');',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
set(hslider_b,'callback',[...			
   'b=get(gcbo,''value'');',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);
set(hslider_r,'callback',[...			
   'r=get(gcbo,''value'');',...		
   'florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)']);

h_push_start_ok=uicontrol(gcf,'style','push',...
    'unit','normalized','position',[0.79,0.10,0.15,0.04],...
    'string','OK','callback','florenz_xyz(htext_speed,str_speed,time,htext_sigma,str_sigma,sigma,htext_b,str_b,b,htext_r,str_r,r,X0,Y0,Z0,t0,tf)');

h_push_start=uicontrol(gcf,'style','push',...
    'unit','normalized','position',[0.79,0.05,0.15,0.04],...
    'string','同步显示开始','callback','my_comet_xyz(X1,X2,X3,t,0.02,time,htext_xyz_t,htext_xyz_x,htext_xyz_y,htext_xyz_z)');


function donghua_x              %图形绕x轴旋转  
global X1 X2 X3 b r rotate_angle rotate_repeat rotate_zhen
figure(14)
str='Roll';
set(gcf,'name',str,'numbertitle','off')

singularity1_x=0;singularity1_y=0;singularity1_z=0;
singularity2_x=(b*(r-1))^(1/2);singularity2_y=(b*(r-1))^(1/2);singularity2_z=r-1;
singularity3_x=-(b*(r-1))^(1/2);singularity3_y=-(b*(r-1))^(1/2);singularity3_z=r-1;

clf;shg,
h=plot3(X1,X2,X3,singularity2_x,singularity2_y,singularity2_z,'k.','MarkerSize',20);
colormap(jet);
axis vis3d,       %旋转时避免图形大小发生变化
grid on,
xlabel('x'),ylabel('y'),zlabel('z'), 

n=360/rotate_angle;mmm=moviein(n);			%预设画面矩阵。
helpdlg('开始图像采集,请稍后......','提示信息');pause(3),
for i=1:n
	rotate(h,[1 0 0],rotate_angle);		%是图形绕z轴旋转4度/每次
 	mmm(:,i)=getframe;			%捕获画面。新版改为mmm(i)=getframe 。
end

ButtonName=questdlg('What is your wish?', ...
                       'Genie Question', ...
                       'replay','roll z','exit Matlab','replay');  
   switch ButtonName,
     case 'replay', 
        movie(mmm,rotate_repeat,rotate_zhen);         %以每秒3帧速度(可调节速度),重复播放4次。 开始会回放一遍
     case 'roll z',
      donghua_z
     case 'exit Matlab',
      quit 
  end 

  
function donghua_y              %图形绕x轴旋转  
global X1 X2 X3 b r rotate_angle rotate_repeat rotate_zhen
figure(14)
str='Roll';
set(gcf,'name',str,'numbertitle','off')

singularity1_x=0;singularity1_y=0;singularity1_z=0;
singularity2_x=(b*(r-1))^(1/2);singularity2_y=(b*(r-1))^(1/2);singularity2_z=r-1;
singularity3_x=-(b*(r-1))^(1/2);singularity3_y=-(b*(r-1))^(1/2);singularity3_z=r-1;

clf;shg,
h=plot3(X1,X2,X3,singularity1_x,singularity1_y,singularity1_z,'k.','MarkerSize',20);
colormap(jet);
axis vis3d,       %旋转时避免图形大小发生变化
grid on,
xlabel('x'),ylabel('y'),zlabel('z'), 
n=360/rotate_angle;mmm=moviein(n);			%预设画面矩阵。
helpdlg('开始图像采集,请稍后......','提示信息');pause(3),

for i=1:n
	rotate(h,[1 0 0],rotate_angle);		%是图形绕z轴旋转4度/每次
	mmm(:,i)=getframe;			%捕获画面。新版改为mmm(i)=getframe 。
end

ButtonName=questdlg('What is your wish?', ...
                       'Genie Question', ...
                       'replay','roll x','roll z','replay');  
   switch ButtonName,
     case 'replay', 
        movie(mmm,rotate_repeat,rotate_zhen);         %以每秒3帧速度(可调节速度),重复播放4次。 开始会回放一遍
     case 'roll z',
      donghua_z
     case 'roll x',
      donghua_x 
   end 

   
function donghua_z              %图形绕z轴旋转  
global X1 X2 X3 b r rotate_angle rotate_repeat rotate_zhen
figure(14)
str='Roll';
set(gcf,'name',str,'numbertitle','off')
set(gcf,'unit','normalized','position',[0.002,0.082,0.9,0.75])

singularity1_x=0;singularity1_y=0;singularity1_z=0;
singularity2_x=(b*(r-1))^(1/2);singularity2_y=(b*(r-1))^(1/2);singularity2_z=r-1;
singularity3_x=-(b*(r-1))^(1/2);singularity3_y=-(b*(r-1))^(1/2);singularity3_z=r-1;

clf;shg,
h=plot3(X1,X2,X3,singularity3_x,singularity3_y,singularity3_z,'k.','MarkerSize',20);
colormap(jet);
axis vis3d,       %旋转时避免图形大小发生变化
grid on,
xlabel('x'),ylabel('y'),zlabel('z'), 
n=360/rotate_angle;mmm=moviein(n);			%预设画面矩阵。
helpdlg('开始图像采集,请稍后......','提示信息');pause(3),

for i=1:n
	rotate(h,[0 0 1],rotate_angle);		%是图形绕z轴旋转度/每次
   	mmm(:,i)=getframe;			%捕获画面。新版改为mmm(i)=getframe 。
end

ButtonName=questdlg('What is your wish?', ...
                       'Genie Question', ...
                       'replay','roll x','roll y','replay');  
   switch ButtonName,
     case 'replay', 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -