Why does a sine bandwidth decrease with 1/dur, dur beeing the signal duration

1 visualización (últimos 30 días)
Dear community, recently i was interested in the bandwidth of spectra. That's why i did some plots for signals with a single frequency at once but for different amplitude, duration and frequency. I saw, that the amplitude and frequency and amplitude does not influence the bandwidth in this case but signal duration does. can someone tell me why and why it is like a constant divided by the duration (~1/x). The constant changes a bit if a analyze the power spectrum instead of PSD, but the behavior stays the same. the behavior also stays the same if take the way over fft function and a linspaced frequency vector here a sample script; for anyone who is confused about the many loops can just set the ampNr and f0 value to one number only.
close all;
fs=8000;
dur=0.1:0.1:2;
cl=lines(6);
amp=1:6;
tiledlayout('flow');
for ampNr=amp
nexttile();
for f0=100:100:1000
myBW=nan(size(dur));
for durNr=1:numel(dur)
t1=0:1/fs:dur(durNr)-1/fs;
s1=sin(2*pi*f0*t1);
s1=s1+rand(size(s1))-0.5;
[spec,fSpec,tSpec,p]=spectrogram(s1,length(s1),[],[],fs);
[val,~,bw]=findpeaks(abs(spec),fSpec,'MinPeakHeight',0.9*max(p));
[~,idx]=max(val);
bw=bw(idx);
myBW(durNr)=bw;
end
end
plot(dur,myBW,'Color',cl(ampNr,:)); hold on;
xlabel('sine duration (s)');
ylabel('bandwidth (Hz)');
title(['sine amplitude ' num2str(ampNr)])
plot(dur,1.76./dur,'--k');
end
linkaxes()
best regards
Jonas

Respuesta aceptada

David Goodmanson
David Goodmanson el 18 de Dic. de 2021
Editada: David Goodmanson el 18 de Dic. de 2021
Hi Jonas,
I believe what you are seeing is just the natural reciprocal relation between width in the time domain and width in the frequency domain of the transformed signal. In physics this is nothing more than the Heisenberg uncertainly principle.
Suppose you have a signal f(t), with a characteristic width (let's say it is determined by the standard deviation) of width t0. Now suppose the same signal is stretched in time by a factor of b. Without getting into details of normalization and so forth, it looks like f(t/b) and its width is b*t0. The transform of the original function is
Int f(t) exp(iwt) dt = g(w)
Suppose it has a width w0. The transform of the stretched function is
Int f(t/b) exp(iwt) dt = Int f(t/b) exp(i(bw)(t/b)) (dt/b) b
and denoting t/b by s,
= Int f(s) exp(i(bw)s) ds b
= g(bw) b
The hanging b is due to not paying attention to normalization and would go away with proper normalization of all this. That doesn't change the fact that the frequency domain function, g(bw) has width w0/b and so is shrunk by the same factor that f(t/b) was expanded by. So the product of widths, width(f)*width(g), is a constant. It's also dimensionless.
As you have alluded to, ploting dur.*myBW gives a nice nearly flat line.
  3 comentarios
Paul
Paul el 18 de Dic. de 2021
I agree with everything @David Goodmanson said. However, I'm not sure that the code actually illustrates the effect that he explains so well.
Consider the code from the OQ, but modified to not add noise to the signal, and modified arguments to spectrogram so that it applies a rectangular window and does no overlap
fs=8000;
dur=0.1:0.1:2;
cl=lines(6);
amp=1:6;
tiledlayout('flow')
for ampNr=amp
nexttile();
for f0 = 100:100:1000
myBW=nan(size(dur));
for durNr=1:numel(dur)
t1=0:1/fs:dur(durNr)-1/fs;
s1=sin(2*pi*f0*t1);
% s1=s1 + (rand(size(s1))-0.5)*0;
% [spec,fSpec,tSpec,p]=spectrogram(s1,length(s1),[],[],fs);
[spec,fSpec,tSpec,p]=spectrogram(s1,0*s1+1,0,numel(s1),fs);
[val,~,bw,prom]=findpeaks(abs(spec),fSpec,'MinPeakHeight',0.9*max(p));
[~,idx]=max(val);
bw=bw(idx);
myBW(durNr)=bw;
end
end
plot(dur,myBW,'Color',cl(ampNr,:)); hold on;
xlabel('sine duration (s)');
ylabel('bandwidth (Hz)');
title(['sine amplitude ' num2str(ampNr)])
plot(dur,1.76./dur,'--k');
end
linkaxes()
Now, let's look closely at how myBW(end) was caculated.
Fist, plot abs(spec)
figure
plot(fSpec,abs(spec),'-o'),grid
xlim([997 1003])
As expected, we see a single peak at 1000 Hz and 0 everywhere else. In other words, looking at the samples of spec one could (rightly?) conclude the signal has zero bandwidth. I suspect that this result obtains because spectrogram() is fft-based and the fft inherently assumes an infinite duration, periodic signal.
The prominence of the peak computed from findpeaks() is
prom
prom = 8.0000e+03
and the width of the peak computed by findpeaks() is the width at 0.5*prom using linear interpolation, which is the width at 4000, which is 0.5
myBW(end)
ans = 0.5000
It seems to me that the elements of myBW are really related to the frequency resolution in the processing. Because fs is fixed, as the duration increases the frequency resolution decreases and it appears that's the effect the code illustrates.
David Goodmanson
David Goodmanson el 19 de Dic. de 2021
Editada: David Goodmanson el 19 de Dic. de 2021
Hi Paul,
You may well be correct. It could boil down to a difference of point of view, though. I took a physics point of view, where scaling arguments apply quite pervasively. In this particular problem, there is an initial idea that the bandwidth is zero. However, some at-the-moment unspecified process has come up with a nonzero bandwidth. With scaling as a general principle and some admitted handwaving, one can argue that no matter what (linear) process was involved, frequency resolution or anything else, the end result will still have to come out width(f)*width(g) = constant. So I think a frequency resolution argument could be tracked back to the scaling law. However, looking at the details of a specific process as you are doing will provide better understanding of what is going on.

Iniciar sesión para comentar.

Más respuestas (1)

Jon
Jon el 16 de Dic. de 2021
Editada: Jon el 16 de Dic. de 2021
I don't have enough time at the moment to look at your code in depth, but I'm suspecting that you are experiencing "leakage" effects by not having an integral number of periods of the signal. So the truncation of your signal causes some extra energy outside of the pure sine frequency.
I suggest that you try changing your duration, but always keep the total duration an integral multiple of the sine wave's period and see if the behavior changes.
  4 comentarios
Jon
Jon el 17 de Dic. de 2021
Editada: Jon el 17 de Dic. de 2021
Sorry, I have not used the spectrogram function, and am not that familiar with the theory behind it In general though, it is aimed at giving you some time resolution of how the frequencies in a time varying signal evolve with time.
This doesn't seem to be directly applicable to your situation where you have pure sine waves.
Obviously a pure sine wave should have only a single frequency in its spectrum. I think if you plot the magnitude of the fft of these signals you will see that.
I think the fact that the peak of the spectrogram, with the parameters that you specified has some finite bandwidth is an artifact of the overlap and add used to compute the spectrogram. It is probably correct, I just don't know how to interpret it without digging deeper.
Hopefully someone else with more expertise on spectrograms can add more on this.
Jonas
Jonas el 18 de Dic. de 2021
the use of the function spectrogram may be confusing here, but in this case i choose the length of the analysis window as the length of the whole signal, this way i have one 1 time bin and dont have to bother with creation of the fft frequency vector, normalization or fftshifting

Iniciar sesión para comentar.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by