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

📄 fdshow.m

📁 信号实验常用的simulink模型和mfile,可直接在matlan下运行。
💻 M
📖 第 1 页 / 共 2 页
字号:
function fdshow(action);
% fdshow   Play the Filter Design Part of the "xhsy" from disk files.
%
% 该软件使用MATLAB语言(版本: 5.1以上), 实现数字滤波器的交互性教学设计. 学生进行实验
% 时, 在软件的指导下, 选择滤波器子类型(如FIR, IIR选择), 输入必要参数(采样频率, 通,
% 阻带频率及衰减), 计算中间数据, 直至得出所要求的滤波器数据, 并进行简单的分析. 从而
% 使学生对数字滤波器设计有一感性认识, 对于其基本步骤和原理有所了解. 能够独立设计数字
% 滤波器.
%
% 西安交通大学,  6/17/99
% See Also:fdslide, mytext1, lbqsjBtns, yhzfdview, yhzzpact, yhzfiltdes...
doi=16;

if nargin<1,
   filename='fdslide';
   action='initialize';
else
   if strmatch('#', action) 
      action=action(2:end);   
   end;   
end;

switch action
case 'initialize',
   LocalInitFigure(filename);
   
case 'next',
   LocalDoCmd(gcbf,+1);
   
case 'back',
   LocalDoCmd(gcbf,-1);

case 'reset',
   %slideData=get(gcbf,'UserData');
   %slideData.index=1;
   %set(gcbf, 'UserData', slideData);   
   LocalDoCmd(gcbf,0);

case 'autoplay',
   figNumber1 = gcbf;
   autoHndl=findobj(figNumber1, 'Type', 'uicontrol', ...
           'Style', 'pushbutton', ...
           'Tag', 'autoPlay');
   if isempty(autoHndl) 
      autoHndl=findobj(figNumber1, 'Type', 'uicontrol', ...
           'Style', 'pushbutton', ...
           'Tag', 'stop');
   end %if    
   allBtns=findobj(figNumber1, 'Type', 'uicontrol', ...
           'Style', 'pushbutton');
   % to check whether Handle is still there in case figure is closed
   if ishandle(autoHndl)
      btnStr=get(autoHndl, 'Tag');
   else
      btnStr='';
   end
   
   if strcmp(btnStr, 'autoPlay')
      slideData=get(figNumber1, 'UserData');
      %cmdlen=length(slideData.slide);
      %n=slideData.index;
      set(allBtns, 'Enable', 'off');
      set(autoHndl, 'String', '停止', 'Enable', 'on','Tag','stop');    
      currentSlide=slideData.path(slideData.index);
      while (currentSlide~=doi+9) & (currentSlide~=doi+26)...
                 & ishandle(autoHndl)...
                 & strcmp(get(autoHndl, 'tag'), 'stop'),
         figure(figNumber1);
      %   slideData=get(figNumber1, 'UserData');
         LocalDoCmd(figNumber1,+1);  
         slideData=get(figNumber1, 'UserData');
         drawnow;
         pause(2);
         %n=n+1;
         currentSlide=slideData.path(slideData.index);
      end;
   end
   if ishandle(autoHndl)
      set(autoHndl, 'String', '演示','Tag','autoPlay');    
      set(allBtns, 'Enable', 'on');
      slideData=get(figNumber1, 'UserData');
     % n=slideData.index;
      LocalEnableBtns(slideData.path(slideData.index), slideData)
   end
   
   % elseif strcmp(action,'info'),
   %    helpwin(mfilename);
   
end;    % switch action
% End of function fdshow

%===========================================
% function LocalInitUserData(nextHndl, backHndl, thandle)
% % Initialize index, slide, param, ...
%     slideData.index=1;
%     slideData.nexthandle=nextHndl;
%     slideData.backhandle=backHndl;
%     slideData.txthandle=thandle;
%     slideData.slide(1).code={''};
%     slideData.slide(1).text={''};
%     slideData.param(1).vars={};
%     set(gcf, 'Userdata', slideData);
%     LocalDoCmd(0);

%==========================================
function LocalDoCmd(figNumber1, rltvpath)
% execute the command in the command window 
% when ichange = 1, go to the next slide;
% when ichange = -1, go to the previous slide;
% when ichange = 0, initialize the original slide;

set(figNumber1, 'Pointer', 'watch');
% retrieve variables from saved UserData workspace

slideData=get(figNumber1,'UserData');

%-------------------------------------------------------------
% make the buttons and texts of last slide invisible
%-------------------------------------------------------------
aHTemp=findobj(figNumber1,'type','axes');
set(aHTemp,'visible','off');
for i=1:length(aHTemp)
   delete(get(aHTemp(i),'Children'));
end   
%delete(get(slideData.axesHandle(2),'Children'));
BtnHandlesTemp=slideData.BtnHandles(slideData.path(slideData.index),:);
for i=1:length(BtnHandlesTemp)
   if BtnHandlesTemp(i)~=0
      set(BtnHandlesTemp(i),'visible','off');
   end;
end;   
%---------------------------------------------------------
%update the next callback string     
%---------------------------------------------------------
[M,N]=size(slideData.slide(slideData.path(slideData.index)).next);
if M~=1
   rltvIndex=slideData.slide(slideData.path(slideData.index)).next(1,1);
   BtnHandlesTemp=slideData.BtnHandles(rltvIndex,:); 
   for i=1:length(BtnHandlesTemp)
       if BtnHandlesTemp(i)~=0 
          if get(BtnHandlesTemp(i),'value')
             nexttemp=slideData.slide(slideData.path(slideData.index)).next(i+1,:);
          end;   
       end;
   end;   % if the next slide index has something to do with the choice before
else nexttemp=slideData.slide(slideData.path(slideData.index)).next;
end;
BtnHandlesTemp=slideData.BtnHandles(slideData.path(slideData.index),:); 
if BtnHandlesTemp(1)==0
   slideData.next=nexttemp(1);
else   
  for i=1:length(BtnHandlesTemp)
     if BtnHandlesTemp(i)~=0
        if (get(BtnHandlesTemp(i),'value'))==1
           slideData.next=nexttemp(i);
        end;   
     end;
  end;
end;  

%-----------------------------------------------------------------
% update the slideData.path which stores the path the fdshow shows
%-----------------------------------------------------------------
if rltvpath==1,
   SlideShowi=slideData.next;
   slideData.index=slideData.index+1;
   slideData.path(slideData.index)=SlideShowi;
elseif rltvpath==-1,
   if slideData.index > 1,
      slideData.index=slideData.index-1;
   end;
   SlideShowi=slideData.path(slideData.index);
else, %rltvpath=0
   slideData.index=1;
   SlideShowi=slideData.path(slideData.index);
end;

cmdlen=length(slideData.slide);

% retrieve the varialbles in the whole program
%if SlideShowi>1
%   SlideShowVars=slideData.param(slideData.index-1).vars;
%  for SlideShown=1:size(SlideShowVars,1); 
%     eval([SlideShowVars{SlideShown,1} '=SlideShowVars{SlideShown,2};']);
%  end;
%end;

%  guarantee the index is always inside the boundary
if SlideShowi<=0,
   SlideShowi=1;
elseif SlideShowi>cmdlen
   SlideShowi=cmdlen;
end   
autoHndl=findobj(figNumber1, 'style', 'pushbutton', 'tag', 'autoPlay');
%stringtemp=get(autoHnd1,'string');
%disp(stringtemp);
if strcmp(get(autoHndl,'tag'), 'autoPlay')
   LocalEnableBtns(SlideShowi, slideData); 
end
% get slides
%SlideShowcmdS=slideData.slide(SlideShowi).code1;
%if length(SlideShowcmdS)>0
%   SlideShowcmdS=char(SlideShowcmdS);
%else
%   SlideShowcmdS='';
%end
%SlideShowcmdNum=size(SlideShowcmdS, 1);   

%------------------------------------------------------------
%display this slide's buttons
%------------------------------------------------------------
BtnHandlesTemp=slideData.BtnHandles(SlideShowi,:);
for i=1:length(BtnHandlesTemp)
   if BtnHandlesTemp(i)~=0
      set(BtnHandlesTemp(i),'visible','on');
      % axz 1999-11-30
      if SlideShowi==1,
         ls_tmp=deblankall(get(BtnHandlesTemp(i),'String'));
         if strcmp(ls_tmp(1:2),'//'),
            set(BtnHandlesTemp(i),'visible','off');
         end;
      end;
      % axz 1999-11-30
   end;
end;   
   
%-------------------------------------------------------------
%display this slide's text
%-------------------------------------------------------------
SlideShowtextStr=slideData.slide(SlideShowi).text;
% consider the empty case
if length(SlideShowtextStr)==0
   set(slideData.txthandle,'visible','off');
   set(slideData.frmHandle,'visible','off');
   % if there is no text, then this area should be prepared to show code2
else 
   set(slideData.txthandle,'visible','on');
   set(slideData.txthandle, 'String', SlideShowtextStr);
end


%------------------------------------------------------
% update the figure title
%------------------------------------------------------
      ttlstring=' ';
      for i=1:slideData.index
         if(i==1)
            ttlstring=strcat(slideData.slide(slideData.path(i)).ttl,ttlstring);
         else if ~isempty(slideData.slide(slideData.path(i)).ttl)           
                 ttlstring=strcat(slideData.slide(slideData.path(i)).ttl,'_',ttlstring);
              end;
         end;     
      end;   
      set(figNumber1,'name',ttlstring);
        
%------------------------------------------------------------
%evaluate the code1 %%%and code2
%------------------------------------------------------------
%for axesnum=1:2
%   if axesnum==1 SlideShowcmdS=slideData.slide(slideData.path(slideData.index)).code1;
%      else       SlideShowcmdS=slideData.slide(slideData.path(slideData.index)).code2;
%   end
 %SlideShowcmdS=slideData.slide(slideData.path(slideData.index)).code1;
 %if ~isempty(SlideShowcmdS)   
      %this code is not empty, so it will be evaluated and displayed
 %     set(gcf,'currentaxes',slideData.axesHandle(1));
 %     SlideShowcmdS=char(SlideShowcmdS);
%else SlideShowcmdS='';
%end
 %     SlideShowcmdNum=size(SlideShowcmdS, 1);   
%sHndl=findobj(figNumber1, 'Type', 'uicontrol', 'Tag', 'slide');
%set(sHndl, 'String', ['Slide ', num2str(SlideShowi)]);

% take comments out of the commands before eval them
%     SlideShowNoCmt=SlideShowcmdS;
%if ~isempty(SlideShowcmdS)
%      SlideShowNoCmt=LocalNoComments(SlideShowcmdS);
%end
%      SlideShowerrorFlag=0;
% add ',' at the end of each command 
%      SlideShowcmdStemp=[SlideShowNoCmt char(','*ones(size(SlideShowcmdS,1),1))];   
% make SlideShowcmdStemp in one line for eval (it has to be that way with 'for' or 'if')
%      SlideShowcmdStemp=SlideShowcmdStemp';
% evaluate the whole command window's code
set(gcf,'currentaxes',slideData.axesHandle(1));
slidePreTxt=slideData.slide(slideData.path(slideData.index)).code1;

⌨️ 快捷键说明

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