MATLAB
3.3 Measure frequency response at single frequency We are now ready to implement a function that measures the frequency response of a LTI system at a single frequency. The function takes a function handle to the system to be measured. Internally it performs the following steps: 1. Generate a complex exponential signal x[n] of the indicated frequency. 2. Pass the complex exponential signal through the system specified by the function handle to generate the output signal y[n]. 3. Measure the frequency response by averaging y[n] - 3*[n] from after the transient until the end of the input signal. Your function must begin like this function H = measure_freq_resp_single (sys_f_handle, $_d, N, L_transition) measure_freq_resp_single - measure the frequency response at a single frequency % $ H = measure_freq_resp_single (sys_f_handle, f_d l, N 1, L_transition]) % & Input Variables: sys_f_hanfle = function handle to LTI system, will be invoked as y = sys_E_handle(x) f_d = normalized frequency (between 0 and 0.5) N = length of signals used for measurement (optional, default: 512) L_transition = length of transition region; will be excluded from measurement (optional, default: 128) & $ $ & Output Variable: H = complex scalar; measured frequency response $check inputs if !isa (sys_f_handle, function_handle' error('measure_freg_resp: first input must be a function handle') end if f_d <0 || _d > 0.5 error('measure_freq_resp: Input parameter {_d must be between 0 and 0.5') end if nargin <3 11 isempty(N) N = 512 end if nargin <4 11 isempty (L_transition) L_transition = 128; end
Verify that your function works correctly by checking selected values of the frequency response of the 10-point averager: 1 and H(0.5) = 0 % check: for 10-pt averager H(0) h = ones (1, 10)/10; measure_freq_resp_single (system_1, 0, 512) measure_freq_resp_single (system_1, 0.5, 512, 10) The expected results are 1 and (very close to) 0, respectively.
MATLAB
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am