Effacer les filtres
Effacer les filtres

Diffrences between input and output signal on filter

1 vue (au cours des 30 derniers jours)
Lukasz Kopec
Lukasz Kopec le 27 Mar 2019
Hello,
I'm trying to calculate diffrences between input and output signal on filter.
Signal that i'm trying to simulate is burst:
ta1=0.00000035;
ta2=0.00000051;
nb=1.8;
kb=exp((-ta1/ta2)*((-nb*ta2/ta1)^(1/nb)));
u=(1000./kb).*(((t./ta1).^nb)./(1+(t./ta1).^nb)).*exp((-t./ta2));%%final signal
Filter that i'm using it supose to simulate real oscilloscope:
pasmo_osc=10000;%%bandwidth
Tg=exp((-((2*pi.*f)./(2*pi*pasmo_osc)).^2)*log(sqrt(2)));
I've tried few different ways but my basic idea was to make FFT of input signal then multiply each frequency component by its magnitude and phase after that make ifft from multiplied signal.
U=fft(u);
ug=(ifft(U.*Tg));
I was expecting that differences between in and out singals will come from bandwidth of scope as it should be. But instead it depends on ratio of frequency used to perform fft and filter bandwidth. Sample rate seams doesnt matter.
Question is, what I'm doing wrong? Is this just stupid idea to this that way? I think something is wrong with fft.
%% time specification
fs=5000; % samples
StopTime = 0.01; % seconds
dt = StopTime/fs; % seconds per sample
t = 0:dt:StopTime-dt;
Tsize=StopTime/dt;
%% signal specification
ta1=0.0035;
ta2=0.0051;
nb=1.8;
kb=exp((-ta1/ta2)*((-nb*ta2/ta1)^(1/nb)));
u=(1000./kb).*(((t./ta1).^nb)./(1+(t./ta1).^nb)).*exp((-t./ta2));
%% fft
pasmo=400000;
krok=pasmo/Tsize;
f = 0:krok:pasmo-krok;
U=fft(u);
%% filter
pasmo_osc=100000;
Tg=exp((-((2*pi.*f)./(2*pi*pasmo_osc)).^2)*log(sqrt(2)));
ug=(ifft(U.*Tg));
plot(t,abs(ug),'b');
hold on
plot(t,abs(u),'r')

Réponses (1)

Star Strider
Star Strider le 27 Mar 2019
I am not certain what you are doing with respect to your oscilloscope simulation. However, if you do an additional plot and look at the frequency domain of your signals and filter, your filter appears to be working correctly:
figure
semilogy(f, abs(U))
hold on
plot(f, abs(Tg))
plot(f, abs(Tg.*U))
hold off
xlabel('Frequency')
legend('Signal','Filter','Output')
It is not always easy to see the effects of a filter in the time domain. It is much easier in the frequency domain.
You appear to be using a FIR filter. See the documentation on fftfilt (link) that does what you are doing, although using a more sophisticated overlap-and-add algorithm.

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by