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

📄 grfhd.asv

📁 线性代数实验及MATLAB入门,电子工业出版社出版 陈怀琛 龚杰民合著
💻 ASV
字号:
function noreturn=grfhd(arg1, arg2, arg3);
% grfhd :  This program handles graph interface for fern - an ATLAST
%   workshop project: 2D/3D Fractal Pictures of Fern!
% This project is developed by: Victor, Daniel, Henry, Herb, Zhang
%    -- szhang@math.udel.edu
 
global sli_1 sli_1cur sli_2 sli_2cur fig cb_box popcol cpop tf np nv cm
global edp x pct

se='Style'; sg='String'; pn='Position'; ck='CallBack';ve='Value';
ut='Unit'; nd='normalized'; 
 
if (nargin == 0 ),
   % Assign a handle to the figure window and clear it
   cm=['yyccbbkkmmrrggyyccbbkkmmrrggyy'];
fig=figure('MenuBar', 'none', 'NumberTitle','off',...
   'Name', 'ATLAST Project: Fractal (Victor, Daniel, Henry, Herb, Zhang - szhang@udel.edu)',...
   'Units', 'normalized'); clf;
ax=axes('Box','on','NextPlot','add',pn,[0.25 0.3 0.75 0.7]);
edp=uicontrol(fig, se,'edit',sg, {['tf=[' gettf(1)];
   ['    ' gettf(2)];  ['    ' gettf(3)];  ['    ' gettf(4)];  ['    ' gettf(5) ']; ']; 'x=[0 0]'';'; 'grfhd(0);'},...
   'HorizontalAlignment', 'left',...
   ut,nd, pn,[0.2 0.01 0.79 0.25],'BackgroundColor',[0.99 0.9 0.7], 'Max',8, ...
   ck, 'eval(char(get(edp,''String''))'')' );
set(fig,'WindowButtonDownfcn',['pct=get(gca,''CurrentPoint'');'...
      'fpara(''ctr'',''1'')'] );
np=8; nv=500;
%Create a push button and a push button for value of a slider
pbstart=uicontrol(fig,se,'push',ut,nd,pn,[.01 .01 .15 .05], sg, 'Plot Now!', ...
   ck, 'grfhd(0)');
uicontrol(fig,se,'push',ut,nd,pn,[0.01 0.9  .15 .045],sg,'Project Info',ck,'fwin(1)');
uicontrol(fig,se,'push',ut,nd,pn,[0.01 0.85 .15 .045],sg,'Theory',ck,'fwin(2)');
uicontrol(fig,se,'push',ut,nd,pn,[0.01 0.8  .15 .045],sg,'Tech Support',ck,'fwin(3)');
uicontrol(fig,se,'push',ut,nd,pn,[0.01 0.72  .15 .045],sg,'Help',ck,'fwin(4)');
uicontrol(fig,se,'push',ut,nd,pn,[0.01 0.67 .15 .045],sg,'Exit',ck,'close');

 %pbgetval=uicontrol(fig,'Style','push','Position',[120 10 120 25],...
 %  'String', 'Get Slider Value',...
 % 'CallBack', 'disp(get(sli_1,''value''))');
uicontrol(fig, se,'text',ut,nd,pn,[0.005 0.29 .16 .18],sg,{'Click mouse to', 'center the graph'}, 'BackgroundColor',[0.99 0.7 0.8]);
uicontrol(fig, se, 'push', sg,' Zoom In ', ut,nd,pn,[0.01 0.3 .15 .045],...
    ve,1,ck,'fpara(''zin'',''1'')');
uicontrol(fig, se, 'push', sg,' Zoom Out', ut,nd,pn,[0.01 0.35 .15 .045],...
   ve,1,ck,'fpara(''zout'',''1'')');
%define sli_1 slider and its text
uicontrol(fig, se,'text',ut,nd,pn,[0.005 0.07 .16 .21], 'BackgroundColor','yellow');
sli_1=uicontrol(fig, se, 'slider',ut,nd, pn, [0.01 0.08 0.15 0.05],...
  'Min', 1, 'Max', 1000, ve, 500, ck,[...
  'set(sli_1cur,''String'',[int2str(fix(get(sli_1,''Value''))) ''pts per level'']),'...
  'fpara(''nv'',int2str(fix(get(sli_1,''Value''))))']);
sli_1cur=uicontrol(fig,se,'text',ut,nd,'Pos',[.01 .125  .15 .037],...
   'String',[int2str(fix(get(sli_1,'Value'))) 'pts per level']);
sli_2=uicontrol(fig, se, 'slider',ut,nd, pn, [0.01 0.19 0.15 0.05],...
  'Min', 2, 'Max', 16, ve, 8, ck,[...
  'set(sli_2cur,''String'',[int2str(fix(get(sli_2,''Value''))) '' levels '']),'...
  'fpara(''np'',int2str(fix(get(sli_2,''Value''))))']);
sli_2cur=uicontrol(fig,se,'text',ut,nd,'Pos',[.01 .24 .15 .036],...
   'String',[int2str(fix(get(sli_2,'Value'))) ' levels ']);
%create check boxes
% txt_1=uicontrol(fig,se,'text', pn, [400 10 100 40], sg, 'check box test');
%cb_box=uicontrol(fig,se,'checkbox',pn, [400 10 100 25],...
%  sg, 'Box=on/off', ck, [  'set(gca,''Box'',''off''),'...
 % 'if get(cb_box,''Value'')==1, set(gca,''Box'',''on''),end' ]);

%create a pop-up menu
popcol=uicontrol(fig, se,'popup',ut,nd,pn,[.01 .5 .15 .05],...
   sg, 'Demo  1|Demo  2|Demo  3|Demo  4|Demo  5|Demo  6|Demo  7|Demo  8|Demo  9|Demo 10|Demo 11|Demo 12|Demo 13|Demo 14|Demo 15|Demo 16|Demo 17', ...
   ve,5,ck, ['fpara(''tf'',[''tf'' int2str(get(popcol,''value''))]);' ...
             'grfhd(''edp'')' ] ); 
cpop=uicontrol(fig, se,'popup',ut,nd,pn,[.01 .6 .15 .05],...
   sg, 'Color|Yellow|Black|Blue|Green|Red', ...
   ve,1,ck,'fpara(''cm'',[''cm'' int2str(get(cpop,''value''))])'); 
  return
end
if(arg1==0),
%Draw now
 k=1; a1=[tf(k,1:2);tf(k,3:4)]; y(:,k)=tf(k,5:6)'; p(k)=tf(k,7);
 k=2; a2=[tf(k,1:2);tf(k,3:4)]; y(:,k)=tf(k,5:6)'; p(k)=tf(k,7)+p(k-1);
 k=3; a3=[tf(k,1:2);tf(k,3:4)]; y(:,k)=tf(k,5:6)'; p(k)=tf(k,7)+p(k-1);
 k=4; a4=[tf(k,1:2);tf(k,3:4)]; y(:,k)=tf(k,5:6)'; p(k)=tf(k,7)+p(k-1);
 k=5; a5=[tf(k,1:2);tf(k,3:4)]; y(:,k)=tf(k,5:6)'; p(k)=tf(k,7)+p(k-1);
   cla; x=[0 0]'; plot(x,'.'); hold on; ax 
   for n=1:np, q=rand(nv,1); clear yy; for m=nv:-1:1; 
         if     q(m)<p(1), x=a1*x+y(:,1);
         elseif q(m)<p(2), x=a2*x+y(:,2);
         elseif q(m)<p(3), x=a3*x+y(:,3);
         elseif q(m)<p(4), x=a4*x+y(:,4);
         else              x=a5*x+y(:,5); end
         yy(m,:)=x'; end,   
      plot(yy(:,1),yy(:,2),[cm(n) '.']); drawnow; 
      if nv==1, if n==np,
            text(yy(1), yy(2), [' pt:' int2str(n) '(done)']); 
         else text(yy(1), yy(2), [' pt:' int2str(n) ]); end
         pause(2); end
   end; hold off;
end
 if (arg1=='edp'),
   set(edp, sg,{['tf=[' gettf(1)]; ...
      ['    ' gettf(2)];  ['    ' gettf(3)]; ...
      ['    ' gettf(4)];  ['    ' gettf(5) ']; ']; 'x=[0 0]'';'; ...
      'grfhd(0);'} );
 end

⌨️ 快捷键说明

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