converting a filter using c2d and the input vector resolution
Ältere Kommentare anzeigen
I would like to have a better understanding of the workflow from filter creating -> converting filter to digital domain -> applying the filter to a vector
I created a 6th order analog butterworth filter with cutoff frequency at 2.841GHz and 2.861GHz. I have a sinusoidal signal at 2851MHz, with the x-axis resoluation at Ts = 1/(100e9). Based on the documentation of filter: https://www.mathworks.com/help/matlab/ref/filter.html#bt_vs4t-1-b, it is a 1D digital filter. Which makes me think I need to convert the analog filter to discrete using c2d. I am confused on what the Ts value for c2d should be. Should it be the resolution value of the input vector? Or it only needs to be 2x the passband frequency? If I use the Ts value of 1/(100e9), my bode result is completely unusable. I read about the article "Using the right model representation" https://www.mathworks.com/help/control/examples/using-the-right-model-representation.html. It shows that by using state-space, my c2d will be more accurate, but I still need to convert to tf for the final filter step, which defeats the purpose of going to ss.
So I have two questions:
- Is there an easier way to simulate this?
- How to pick a proper Ts value?
Thanks!
fc = 2851.3e6; % resonate freq
fs = 100e9; % x axis resolution
Ts = 1/fs;
t_start = 0; % x axis start time
t_stop = 10e-6; % x axis stop time
t = (t_start):(Ts):(t_stop); % x axis
rf = cos((2*pi*f_c*(t)) + (0));
% External BPF
lp_f = 2.841e9;
hp_f = 2.861e9;
lp_w = 2*pi*lp_f;
hp_w = 2*pi*hp_f;
ext_bpf_bw = [lp_w hp_w];
[ext_bpf_Num, ext_bpf_Den] = butter(6, ext_bpf_bw, 'bandpass','s'); % create a butterworth filter
ext_bpf = tf(ext_bpf_Num, ext_bpf_Den);
opt = c2dOptions('Method','matched','FractDelayApproxOrder', 3);
ext_bpfz = c2d(ext_bpf, (Ts), opt);
figure()
P = bodeoptions('cstprefs');
P.Xlim = [2.7, 3.0];
P.FreqUnits = 'GHz';
P.Title.String = 'Ext RF filter';
P.Grid = 'on';
bodeplot(ext_bpf, ext_bpfz, 'x',P);
ext_bpf_out = filter(ext_bpfz.Num{1}, ext_bpfz.Den{1}, rf);
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Analog Filters finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!