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

📄 ctcongui.m

📁 ADSP TOOLBOX: Version 2.0 and gui m-files
💻 M
📖 第 1 页 / 共 2 页
字号:
   t_step = eval(['[',t_st,']'],'[]');
   if isempty(t_step)
      errordlg('MATLAB syntax error for time step.','Input Error');
      return;
   end

   if length(t_step)~=1,
       errordlg('Only one value required for time step.','Input Error');
      return;
   end

   if t_step <=0,
       errordlg('Time step must be positive.','Input Error');
      return;
   end

% obtain local range values
   n_str = get(n_edt,'string');
   if isempty(n_str)
      errordlg('No values entered for range for x(t).','Input Error');
      set(action_pop,'value',1);
      return;
   end
   n_val = eval(['[',n_str,']'],'[]');
   if isempty(n_val)
      errordlg('MATLAB syntax error for range of x(t).','Input Error');
      set(action_pop,'value',1);
      return;
   end
   if length(n_val)~=2
      errordlg('Range for x(t) requires 2 end values.','Input Error');
      set(action_pop,'value',1);
      return;
   end
   minn=n_val(1);maxn=n_val(2);
   if minn >= maxn,
      errordlg('Range for x(t)  must be entered as  min, max.','Input Error');
       set(action_pop,'value',1);
       return;
   end

      xn_str = get(xn_edt,'string');
          if ~length(xn_str)
             errordlg('No Matlab array entered for x(t)!','Input Error');
       set(action_pop,'value',1);
             return;
          end

problem=0;if xn_str(1)=='W',
xn_str(1)=[];xn_st=xn_str;evalin('base',[xn_str ';'],'problem=1;')
if problem==0, xn_str=evalin('base',xn_str);
else
   errordlg('MATLAB Syntax error.','Input Error');
   return
end
end
      t=minn:t_step:maxn;

if isstr(xn_str)
      xn_str = ['[',xn_str,']'];
      tx=t;
      ttt=0;
      eval([xn_str ';'],'ttt=1;');
      if ttt
         errordlg('Incorrect Matlab syntax for x(t).','Input Error');
       set(action_pop,'value',1);
         return;
      end
      xn_eval = eval(xn_str);
else
      xn_eval=xn_str;
end

      if length(xn_eval) ~= length(t) & length(xn_eval) ~= 1
     errordlg('Array length must equal range length for x(t).','Input Error');
       set(action_pop,'value',1);
         return;
      end

   if length(xn_eval)==1
      xn_eval=xn_eval*ones(size(tx));
   end


   set(n_edt,'userdata',tx);
   set(xn_edt,'userdata',xn_eval);


% obtain local range values
   n_str = get(ui(10),'string');
   if isempty(n_str)
      errordlg('No values entered for range for h(t).','Input Error');
      set(action_pop,'value',1);
      return;
   end
   n_val = eval(['[',n_str,']'],'[]');
   if isempty(n_val)
      errordlg('MATLAB syntax error for range of h(t).','Input Error');
      set(action_pop,'value',1);
      return;
   end
   if length(n_val)~=2
      errordlg('Range for h(t) requires 2 end values.','Input Error');
      set(action_pop,'value',1);
      return;
   end
   minn=n_val(1);maxn=n_val(2);
   if minn >= maxn,
      errordlg('Range for h(t)  must be entered as  min, max.','Input Error');
       set(action_pop,'value',1);
       return;
   end

      hn_str = get(ui(12),'string');
          if ~length(hn_str)
             errordlg('No Matlab array entered for h(t)!','Input Error');
       set(action_pop,'value',1);
             return;
          end

problem=0;if hn_str(1)=='W',
hn_str(1)=[];hn_st=hn_str;evalin('base',[hn_str ';'],'problem=1;')
if problem==0, hn_str=evalin('base',hn_str);
else
   errordlg('MATLAB Syntax error.','Input Error');
   return
end
end
      t = minn:t_step:maxn;
      th=t;

if isstr(hn_str)
      hn_str = ['[',hn_str,']'];
      ttt=0;
      eval([hn_str ';'],'ttt=1;');
      if ttt
         errordlg('Incorrect Matlab syntax for h(t).','Input Error');
       set(action_pop,'value',1);
         return;
      end
      hn_eval = eval(hn_str);
else
     hn_eval = hn_str;
end

      if length(hn_eval) ~= length(t) & length(hn_eval) ~= 1
      errordlg('Array length must equal range length for h(t).','Input Error');
       set(action_pop,'value',1);
         return;
      end
   if length(hn_eval)==1
      hn_eval=hn_eval*ones(size(th));
   end

   set(h_edt,'userdata',th);
   set(hn_edt,'userdata',hn_eval);

   ty=get(action_pop,'value');
   set(ui([20:21]),'vis','off');

   if ty==1
   set(ui([4,6,7,10,12]),'enable','on');
%   set(ui([15:17,20:21]),'vis','off');
   set(ui([15:17]),'vis','off');
   set(top_axs,'pos',[210 260 390 160]);
   set(bot_axs,'pos',[210 40 390 160]);
   set(sig_axs,'pos',[-600 260 390 160]);
   set(opr_axs,'pos',[-600 40 390 160]);
   set(ui(27),'xdata',[tx(1) tx tx(length(tx))],'ydata',[0 xn_eval 0]);
   set(ui(29),'xdata',[th(1) th th(length(th))],'ydata',[0 hn_eval 0]);
   tmin=min([tx th]);tmax=max([tx th]);delt=0.1*(tmax-tmin);
   ymin=min([xn_eval hn_eval]);ymax=max([xn_eval hn_eval]);
%%% New code
   if ymin>0,ymin=0;end
   if ymax<0,ymax=0;end
%%%
   dely=0.1*(ymax-ymin);
   set([top_axs,bot_axs],'xlim',[tmin-delt tmax+delt]);
   set([top_axs,bot_axs],'ylim',[ymin-dely*(ymin~=0) ymax+dely*(ymax~=0)]);
   drawnow;
   return
   else
   set(ui([4,6,7,10,12]),'enable','off');
   set(top_axs,'pos',[-600 260 390 160]);
   set(bot_axs,'pos',[-600 40 390 160]);
   set(sig_axs,'pos',[210 260 390 160],'color','k');
   set(opr_axs,'pos',[210 40 390 160]);
%   set(ui([20:21]),'vis','off');
   ctconplt;
   set(ui([15:17]),'vis','on');

   end

elseif mode == 3, % edit fields
%   if get(autoplot,'value'), fsrplt; end



elseif mode == 15, %Export data
%%%%% EXAMPLE: Change for each gui %%%%%
str1='Export signal x(t) as';
str2='Export index of x(t) as';
str3='Export signal h(t) as';
str4='Export index of h(t) as';
str5='Export result y(t) as';
str6='Export index of y(t) as';
exp_str={str1,str2,str3,str4,str5,str6};
exp_var={'xsig','xind','hsig','hind','ysig','yind'};

expect=inputdlg(exp_str,'Save Variables as',1,exp_var);
if ~isempty(expect)
txsig=get(ui(4),'userdata');%%% FIX FOR UIs 
xsig=get(ui(6),'userdata');%%% FIX FOR UIs 
thsig=get(ui(10),'userdata');%%% FIX FOR UIs 
hsig=get(ui(12),'userdata');%%% FIX FOR UIs 
tysig=get(ui(7),'userdata');
ysig=get(ui(8),'userdata');
if ~isempty(expect{1}),assignin('base',expect{1},xsig);end
if ~isempty(expect{2}),assignin('base',expect{2},txsig);end
if ~isempty(expect{3}),assignin('base',expect{3},hsig);end
if ~isempty(expect{4}),assignin('base',expect{4},thsig);end
if ~isempty(expect{5}),assignin('base',expect{5},ysig);end
if ~isempty(expect{6}),assignin('base',expect{6},tysig);end
end


elseif mode == 20, % mouse functionality
cur_axs = [];   cur_obj = gco;
   cur_par = get(cur_obj,'parent');
if ~isempty(cur_par)
   if cur_par == f,
      cur_axs = cur_obj;
   else
      cur_axs = cur_par;
   end
end


if isempty(cur_axs)
msgbox([' Click in the result window after operation.                    ',... 
'                  Then, come back and execute'],...
'Axis Control Info','help')
return,
end
   if any(cur_axs == [opr_axs]),
      axes(cur_axs);
         tit_str = get(get(cur_axs,'title'),'string');
         axs_pos = get(cur_axs,'pos');
         if axs_pos(4) == 160, % need to maximize
            if cur_axs == sig_axs,
            else
               set(sig_axs,'pos',[-600,260,390,370]);
            end
            set(cur_axs,'pos',[210,40,390,370],'vis','on');

         else % minimization

              set(sig_axs,'pos',[210,260,390,160],'vis','on','color','k');
              set(opr_axs,'pos',[210,40,390,160],'vis','on');
 
         end
      else
msgbox([' Click in the result window after operation.                   ',... 
'                  Then, come back and execute'],...
'Axis Control Info','help')
return,

   end


end


⌨️ 快捷键说明

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