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

📄 f_getsys.m

📁 DSP程序 Matlab是一套用于科学工程计算的可视化高性能语言与软件环境。它集数值分析、矩阵运算、信号处理和图形显示于一体
💻 M
字号:
function [x,N,fs,a,b,user,xm,xm_old] = f_getsys (xm,xm_old,N,N_max,fs,f0,a,b,c,x,user,hc_type);

%F_GETSYS: Compute input for GUI module G_SYSTEM
%
% Usage: [x,N,fs,a,b,user,xm,xm_old] = f_getsys (xm,xm_old,N,N_max,fs,f0,a,b,c,x,user,hc_type);
%
% Inputs: 
%         xm      = type of input 
%
%                   1 = white noise
%                   2 = unit impulse
%                   3 = unit step 
%                   4 = damped cosine  
%                   5 = record sound
%                   6 = user-defined  
%
%         xm_old  = previous value for xm
%         N       = number of samples
%         N_max   = maximum number of samples
%         fs      = sampling frequency
%         f0      = frequency of damped cosine (0 to fs/2)
%         a       = denominator coefficient vector
%         b       = numerator coefficient vector
%         c       = damping factor of damped cosine input
%         x       = vector of length containing original input sampless 
%         user    = string containing default name for user MAT-file
%         hc_type = array of type radio button handles
% Outputs: 
%          x      = 1 by N_max vector of zero-padded samples
%          N      = number of samples
%          fs     = sampling frequency
%          a      = denominator coefficient vector
%          b      = numerator coefficient vector
%          user   = string containing name for user MAT-file
%          xm     = type of input
%          xm_old = previous value for xm

% Initialize

k = [0 : N-1]';
T = 1/fs;

switch (xm)
   
case 1,                                          % white noise   
   
   x = f_randu (N,1,-1,1); 
   
case 2,                                          % unit impulse
   
   x = [1 ; zeros(N-1,1)];
   
case 3,                                          % unit step
   
   x = ones(N,1);
   
case 4,                                          % damped cosine
   
   x = c.^k .* cos(2*pi*f0*k*T);
   
case 5,                                          % record sound
   
  [x,N,xm,fs] = f_record (x,N,1.0,fs,xm,xm_old,hc_type);
   
case 6,                                          % user defined

   caption = 'Select MAT-file containing a,b,x,fs';
   [user1,path] = f_getmatfile (caption,user);
   if user1 ~= 0
       user = user1;
       old_path = pwd;
       cd (path);
       load (user,'a','b','x','fs')
       cd (old_path)
   else
       set (hc_type(xm),'Value',0);
       set (hc_type(xm_old),'Value',1);
       xm = xm_old;
   end

end

% Update xm and Check x

xm_old = xm;
N = length(x);
if N > N_max
   x(N_max+1:N) = [];
   N = N_max;
end

⌨️ 快捷键说明

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