How do I convolve a transfer function with a rect function?
Afficher commentaires plus anciens
I made this simple low pass filter (the transfer function "h") and I wanted to see the output signal when I pass a square rectangular pulse. My plan was to multiple the rect pulse in frequency domain with the transfer function and plot the output, but I kept getting an error.
Blow is what I had in mind:
%simple low pass filter with cut-off frequency of 1GHz and gain of 1v/v
f = 1E9;
w = 2*pi*f;
h = tf([0 w], [1 w]); %transfer function
%make a impulse in the time domain and transfer it to freq domain
step = 3E-16; %above this val my computer will become a drone
fs = 1/step; %sampling frequency
t = 0:step: 100E-12;
T = 50E-12; %width of my signal
x = rectpuls(t-T, T);
figure(1)
plot(t,x)
grid
%perform FFT
l = length(x); %lenght of my signal
n = 2^nextpow2(l); %fft only work when the l is n^2
fr = fs/n; %frequency resolution
fn = fs/2; %everything after fn is in the negative spect
X = fft(x,n); %this will plot
ff = -fs/2: fr : fs/2-1;
Xshifted = abs(fftshift(X));
figure(2)
plot(ff, h*Xshifted); %~~~~~~~~~~~~~~~~I am getting an error here~~~~~~~~~~~~~
How can I plot the frequency response of my system h due to the rect pulse?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Digital Filter Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!