• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Butterworth order and curves

try to add the high pass lines after the audioread

[X, Fs] = audioread(input_file);
[b, a] = butter(8, 100/(Fs/2), "high");
X = filter(b, a, X);
That's 8th order filter and for me it overloads or something. The values of the samples in the filtered signal go extremely negative and then turn to NaN. Here's at 00:01:
Code:
X(1*Fs:1*Fs+10)
ans =

  -1.2849e+40
  -1.2888e+40
  -1.2927e+40
  -1.2966e+40
  -1.3005e+40
  -1.3044e+40
  -1.3084e+40
  -1.3123e+40
  -1.3163e+40
  -1.3202e+40
  -1.3242e+40
and at 00:10:
Code:
X(10*Fs:10*Fs+10)
ans =

   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN

All looks fine with lower orders or with 8th order but higher frequency e.g. 200.
 
Last edited:
That's 8th order filter and for me it overloads or something. The values of the samples in the filtered signal go extremely negative and then turn to NaN. Here's at 00:01:
Code:
X(1*Fs:1*Fs+10)
ans =

  -1.2849e+40
  -1.2888e+40
  -1.2927e+40
  -1.2966e+40
  -1.3005e+40
  -1.3044e+40
  -1.3084e+40
  -1.3123e+40
  -1.3163e+40
  -1.3202e+40
  -1.3242e+40
and at 00:10:
Code:
X(10*Fs:10*Fs+10)
ans =

   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN

All looks fine with lower orders or with 8th order but higher frequency e.g. 200.

The problem with 2nd order butterworth is it causes a sharp slope

spectrum.png

But with the EEG file (attached), I can make it 8th order at Octave, but not the BMAshort file.

spectrum.png


The following is from Matlab command "X = highpass(signal,100,Fs);", the 100Hz cutoff is brick wall . What butterworth order is the default Matlab command? and how do you make brickwall cutoff in Octave? File attach is the same EEG file. Pls try to make the cutoff brick wall too. Also how come 8th order can make the EEG file run (BMAEEG attached) but not BMAshort.wav for 100Hz (important cutoff to eliminate 60Hz AC, 200Hz cutoff would be too far)? Isn't it it should be consistent.



matlab egg 100hz hp.JPG
 

Attachments

Last edited:
It's ok if Octave can't do brickwall cutoff. Matlab is the most powerful software in the planet, almost A.I. powered, so it can find a way to make brick wall cutoff, while Octave needs only to do approximations like you do in real circuits via Butterworth order 2, 3, 4 etc. to make cutoff.

But Octive is free and the windowing function is already listed in your codes, something difficult for me to append different codes to the core fft codes I got. So I want to use your code to visualize all the log plots I missed before.

The last thing I want to do before focusing back on the application is reading hd5f, Im reading about this all day.

First. what does pkg install -forge xxxx means? Is it like it is possible to install plugs in made by different parties in Octave?? And the following are different ways to install hdf5 input and output? Are there other examples where different plug ins made by different sources produce the same task?



Are there dozens or maybe even hundreds of such plugins? So Octave is like open source that different programmers can append plugin? I need to know before I ask about best way to read hdf5 in stack overflow. If one doesn't ask proper question there, one can get blocked immediately. Thank you.
 
That's 8th order filter and for me it overloads or something. The values of the samples in the filtered signal go extremely negative and then turn to NaN. Here's at 00:01:
Code:
X(1*Fs:1*Fs+10)
ans =

  -1.2849e+40
  -1.2888e+40
  -1.2927e+40
  -1.2966e+40
  -1.3005e+40
  -1.3044e+40
  -1.3084e+40
  -1.3123e+40
  -1.3163e+40
  -1.3202e+40
  -1.3242e+40
and at 00:10:
Code:
X(10*Fs:10*Fs+10)
ans =

   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN
   NaN

All looks fine with lower orders or with 8th order but higher frequency e.g. 200.

Whew. I finally figured out how to read hdf5 file. And with my experience in manipulating dataset in Matlab like changing data from rows to column and reading one column or row. I am able to make it work in Octave, even the samples jump by inputting the sample to skip and it automatically figure out the fft length and where to skip and deduct the dataset.

I can agree that Octave is like Matlab. I read someone in stack exchange commenting how Octave wants to do better than Matlab that is why it changes many syntax, and it said the programmers didn't realize Matlab is still the standard. And wish they had made the syntax totally compatible with Matlab so you can run Matlab codes in Octave, do you agree?

Just last thing I wanna know. How do you recognize when an FFT would not work with 8th order butterworth and only 2th order? I guess when someone will make a new plugin, perhaps he can make it brick wall like in Matlab cuttoff filter, isn't it? And it is ok for now while learning about windowing and Welch, etc. Thanks for your code and the assistance. Can finally explore log in more details.
 
What butterworth order is the default Matlab command?
I'm not sure if it is butterworth. This post says it is elliptical:

According to documentation, it is either "fir" or "iir":

and how do you make brickwall cutoff in Octave?
Code:
b = fir1(512, 100/(Fs/2), "high");
X = filter(b, 1, X);
spectrum.fir.png

Also works with bmashort.wav.

But there are probably many things to consider when choosing the type of filter and I'm not an expert, so I can't say if the above is optimal or even sane :) .

Also how come 8th order can make the EEG file run (BMAEEG attached) but not BMAshort.wav for 100Hz
I have no idea. If I had to guess, I'd say that maybe it has something to do with the percentage of the bandwidth it works on? bmaeeg has 4 kHz bandwidth, so 100 Hz is 2.5%, bmashort has 22 kHz bandwidth and 100 Hz is 0.45%. Maybe that's too little. But that's just guessing.

How do you recognize when an FFT would not work with 8th order butterworth and only 2th order?
After applying the filter all the samples of the signal should still be in [-1:1] range. But with 8th order I get:
Code:
max(X)
ans = Inf

min(X)
ans = -2.6832e+306
That's obviously out of [-1:1] range and is a good indicator that something went wrong.
 
I'm not sure if it is butterworth. This post says it is elliptical:

According to documentation, it is either "fir" or "iir":


Code:
b = fir1(512, 100/(Fs/2), "high");
X = filter(b, 1, X);
View attachment 477937
Also works with bmashort.wav.

But there are probably many things to consider when choosing the type of filter and I'm not an expert, so I can't say if the above is optimal or even sane :) .


I have no idea. If I had to guess, I'd say that maybe it has something to do with the percentage of the bandwidth it works on? bmaeeg has 4 kHz bandwidth, so 100 Hz is 2.5%, bmashort has 22 kHz bandwidth and 100 Hz is 0.45%. Maybe that's too little. But that's just guessing.


After applying the filter all the samples of the signal should still be in [-1:1] range. But with 8th order I get:
Code:
max(X)
ans = Inf

min(X)
ans = -2.6832e+306
That's obviously out of [-1:1] range and is a good indicator that something went wrong.

Many thanks. For the following inputs shorted linear plot. How does one make a program such that when you plot it, it will be renormalized, meaning the new FFT will have entire noise floor that is flat at 0 magnitude. In other words, renormalized so one can easily see signal just above the noise floor. Maybe one needs to know the maximum of each bin and then renormalized it to zero, how does one do it, and not also accepting the random peak in each bin but by following the integral? I don't use log because when the signal is so close to noise floor, log can make it invisible.

spectrum.png
 
danadam, you wrote something in the site that got me thinking a lot about Welch. First you wrote:

"Convert to the desired units​

The initial results are interpreted as power spectrum [V_rms^2]. By default they are converted to peak linear spectrum:

% Convert from power spectrum [V_rms^2] to peak linear spectrum [V_peak]<br>Y = sqrt(mag2) * sqrt(2);<br>
The conversion can be removed if you want power spectrum, or it can be changed to (rms) linear spectrum:

% Convert from power spectrum [V_rms^2] to linear spectrum [V_rms]<br>Y = sqrt(mag2);"


How do I know if my signal is in power spectrum (V_rms^2) or linear spectrum? What if my signal is in linear spectrum and Matlab and Octave reading it in power spectrum?

Also the EEG/EMG I'm doing or replicating is supposed to detect in PSD (Power Spectral Density), but I ignored it for 2 reasons. First, in this comparison:

comparisons.jpg



You can see all peaks in FFT of the PSD. So I thought, why bother with PSD when one can just use FFT. Can you mention one case where you can only see signal with PSD that you can't with FFT. I read also that PSD is used if the signal is changing. In my bioamplifier, the signal is changing? so what would I miss if I just use FFT? Two months ago. I copied a subroutine for Matlab Welch. I thought about it now too because it may be the best way to renormalize the baseline of the noise.

[signal1,Fs] = audioread('bmashort.wav');
T = 1/Fs; % Sampling period
signal2 = signal1(:,1);
X = double(signal2);
signal = X - mean(X);


% Define parameters for Welch's method
Fs = 44100; % Replace with your actual sampling frequency
nperseg = 7228; % Segment length (adjust as needed)
noverlap = nperseg/2; % Overlap (e.g., 50% overlap)

% Calculate the PSD using Welch's method
[power_spectrum, frequencies] = pwelch(signal, hamming(nperseg), noverlap, nperseg, Fs);

% Plot the PSD
figure;
semilogy(frequencies, power_spectrum);
xlabel('Frequency (Hz)');
ylabel('Power Spectral Density (PSD)');
title('Welch Power Spectral Density Estimate');
grid on;


bmashort welch small segment.JPG


Before exploring how to save the baseline and deduct it from every line in the dataset column to make it flat. First mention a case where you can see time varying signal in PSD that you can't in FFT. Btw. Octave has no command for Welch?
 
Last edited:
How do I know if my signal is in power spectrum (V_rms^2) or linear spectrum? What if my signal is in linear spectrum and Matlab and Octave reading it in power spectrum?
The signal is neither power nor linear spectrum. It's just signal. Those terms apply only to the result of FFT. You transform the results one way and you get power spectrum or you transform them another way and you get linear spectrum. Which one you choose depends on what you want to show or what you are interested in. Below is a single signal, let's say it is a recorded voltage. If you are interested in the voltage of the signal's components, then linear spectrum:
spectrum.Vrms.png

shows that 6k is 10 times larger than 12k. If you are interested in the power of the signal's components, then power spectrum:
spectrum.Vrms2.png

shows that 6k has 100 times more power than 12k.

Can you mention one case where you can only see signal with PSD that you can't with FFT.
AFAIU:
  • spectrum is used when you are interested in peaks because (in spectrum) peaks' levels are not dependent on FFT size (and noise level is).
  • spectral density is used when you are interested in noise because (in spectral density) noise level is not dependent on FFT size (and peaks levels are).
The same signal on all graphs, spectrum on top, spectral density below:
spectrum_vs_density.png


Btw. Octave has no command for Welch?
It has one:
 
The signal is neither power nor linear spectrum. It's just signal. Those terms apply only to the result of FFT. You transform the results one way and you get power spectrum or you transform them another way and you get linear spectrum. Which one you choose depends on what you want to show or what you are interested in. Below is a single signal, let's say it is a recorded voltage. If you are interested in the voltage of the signal's components, then linear spectrum:
View attachment 478330
shows that 6k is 10 times larger than 12k. If you are interested in the power of the signal's components, then power spectrum:
View attachment 478331
shows that 6k has 100 times more power than 12k.


AFAIU:
  • spectrum is used when you are interested in peaks because (in spectrum) peaks' levels are not dependent on FFT size (and noise level is).
  • spectral density is used when you are interested in noise because (in spectral density) noise level is not dependent on FFT size (and peaks levels are).
The same signal on all graphs, spectrum on top, spectral density below:
View attachment 478335


It has one:

Thanks for your great illustrations. I could have missed the concept for a long time.

Yesterday when figuring out what I thought was the signal having power spectrum. I tried to read all about how RMS was derived. I saw this:

Vrms.jpg



What kept me wondering was why square the voltage. I even asked a mathematician. I asked what happens if one sums the square of 1,2,3. and get 3.74. He said that 3.74 is the length of the diagonal of a rectangular 3D box with dimensions 1, 2, and 3. I asked him about the above. He said he was not familiar with electrical.

So why square the voltage and not cube it or just using the column without square? What in the sine wave figure can make one square the voltage?
 
Root mean square voltage is the equivalent voltage in constant DC that will give the same averaged power as the AC waveform (when averaged in integer periods of the AC waveform, or if the number of periods in non-integral, large number of periods). Since power = voltage² / resistance (for resistive loads), the math just works out that way.

What-is-RMS-Voltage.png

See:
 
You can see all peaks in FFT of the PSD. So I thought, why bother with PSD when one can just use FFT.
Taking FFT of a signal means doing one single transform - no averaging, any signal. By PSD people usually mean taking FFTs of (windowed) pieces of a stationary signal and averaging them. Let's say we have a 1-minute long 48 kHz signal - there is a big difference between running one FFT of length 2880000 and averaging a hundred or two of little FFTs (for example, of length 32768).

Squaring (and resulting units of measure) is a byproduct of how PSD and its estimation methods are derived. Also affects interpretation of coefficients, as noted above.

What kept me wondering was why square the voltage. I even asked a mathematician. ...I asked him about the above. He said he was not familiar with electrical.

So why square the voltage and not cube it or just using the column without square? What in the sine wave figure can make one square the voltage?
Remind the mathematician about Parseval's theorem - squaring gets you a beautiful relationship between time and frequency domain. If it wasn't like that then a lot of other signal math would work out very differently.
 
Root mean square voltage is the equivalent voltage in constant DC that will give the same averaged power as the AC waveform (when averaged in integer periods of the AC waveform, or if the number of periods in non-integral, large number of periods). Since power = voltage² / resistance (for resistive loads), the math just works out that way.

What-is-RMS-Voltage.png

See:

This was what I googled a lot yesterday. Is squaring has to do with the integral (with area hence need squaring see below) or is it because of the formula power = voltage² / resistance with power proportional to voltage square? Many web site mentions the latter, but it is not the real reason why the voltage is squared isn't it? And using the formula is a wrong reason, right?

rms integral.jpg
 
Taking FFT of a signal means doing one single transform - no averaging, any signal. By PSD people usually mean taking FFTs of (windowed) pieces of a stationary signal and averaging them. Let's say we have a 1-minute long 48 kHz signal - there is a big difference between running one FFT of length 2880000 and averaging a hundred or two of little FFTs (for example, of length 32768).

Squaring (and resulting units of measure) is a byproduct of how PSD and its estimation methods are derived. Also affects interpretation of coefficients, as noted above.


Remind the mathematician about Parseval's theorem - squaring gets you a beautiful relationship between time and frequency domain. If it wasn't like that then a lot of other signal math would work out very differently.

When you do spectral density of FFT and do many averages. Does it automatically become PSD? In danadam FFT. He can do averaging and uses power spectrum or spectral density. But how come it is still FFT?


The signal is neither power nor linear spectrum. It's just signal. Those terms apply only to the result of FFT. You transform the results one way and you get power spectrum or you transform them another way and you get linear spectrum. Which one you choose depends on what you want to show or what you are interested in. Below is a single signal, let's say it is a recorded voltage. If you are interested in the voltage of the signal's components, then linear spectrum:
View attachment 478330
shows that 6k is 10 times larger than 12k. If you are interested in the power of the signal's components, then power spectrum:
View attachment 478331
shows that 6k has 100 times more power than 12k.


AFAIU:
  • spectrum is used when you are interested in peaks because (in spectrum) peaks' levels are not dependent on FFT size (and noise level is).
  • spectral density is used when you are interested in noise because (in spectral density) noise level is not dependent on FFT size (and peaks levels are).
The same signal on all graphs, spectrum on top, spectral density below:
View attachment 478335


It has one:

Isn't it PSD is exactly doing power spectrum or getting power and doing many averages? Yet you are doing that to FFT. How does it differ to PSD?
 
Last edited:
The signal is neither power nor linear spectrum. It's just signal. Those terms apply only to the result of FFT. You transform the results one way and you get power spectrum or you transform them another way and you get linear spectrum. Which one you choose depends on what you want to show or what you are interested in. Below is a single signal, let's say it is a recorded voltage. If you are interested in the voltage of the signal's components, then linear spectrum:
View attachment 478330
shows that 6k is 10 times larger than 12k. If you are interested in the power of the signal's components, then power spectrum:
View attachment 478331
shows that 6k has 100 times more power than 12k.


AFAIU:
  • spectrum is used when you are interested in peaks because (in spectrum) peaks' levels are not dependent on FFT size (and noise level is).
  • spectral density is used when you are interested in noise because (in spectral density) noise level is not dependent on FFT size (and peaks levels are).
The same signal on all graphs, spectrum on top, spectral density below:
View attachment 478335


It has one:

Something confusing. When you square a value less than 1 like 0.5, you get even smaller value like 0.25. But is it not getting the power from V^2 is supposed to get bigger value? But in the spectrum in the first 2 images (linear spectrum vs power spectrum). You get lower peak (10^-2) when getting the power spectrum (vs 10^-1 in linear spectrum), why is that??

Also if the signal I'm looking for not just one peak but broadband peak like the following. Is FFT or PSD better?

broadband peak.jpg



Another thing. How come in your Octave code you have to add the following to convert power spectrum to linear spectrum? But in Matlab there is no conversion.

% Convert from power spectrum in V_rms^2 to linear spectrum in V_peak
Y = sqrt(mag2) * sqrt(2);

Does that mean Matlab is already in linear spectrum? To test it. I tried to add the following line "P1=P1^2/sqrt (2)" to the Matlab code to run it in power spectrum.


matlab error.JPG


But it has the error. How do you insert the line "P1=P1^2/sqrt (2)" in it? Many thanks.
 
When you do spectral density of FFT and do many averages. Does it automatically become PSD? In danadam FFT. He can do averaging and uses power spectrum or spectral density. But how come it is still FFT?
I don't understand the question

There is a big difference between
1) Applying a Fourier transform to a signal. FFT is merely a practical algorithm for computing Fourier transform in the discrete world. It is a tool that does a well defined thing - not more, not less. I beg you to remember this every time you say or write "FFT". If your signal is 100000 samples then the plotted spectrum will have 100000/2+1=50001 frequency bins.
2) Estimating some theoretical quantity like spectral density. Usually that is done via applying FFT to signal chunks + some averaging across different chunks. If your chunks are of length 2048, then your spectral density estimate will have 1025 frequency bins.

Units of measurement are a secondary thing here and are easily converted back and forth by squaring or taking a square root. Which is just multiplication and division by 2 when you are in decibel land.

Re: Matlab error - please read the error, it literally tells you what to do
 
Last edited:
I don't understand the question

There is a big difference between
1) Applying a Fourier transform to a signal. FFT is merely a practical algorithm for computing Fourier transform in the discrete world. It is a tool that does a well defined thing - not more, not less. I beg you to remember this every time you say or write "FFT". If your signal is 100000 samples then the plotted spectrum will have 100000/2+1=50001 frequency bins.
2) Estimating some theoretical quantity like spectral density. Usually that is done via applying FFT to signal chunks + some averaging across different chunks. If your chunks are of length 2048, then your spectral density estimate will have 1025 frequency bins.

Units of measurement are a secondary thing here and are easily converted back and forth by squaring or taking a square root. Which is just multiplication and division by 2 when you are in decibel land.

Re: Matlab error - please read the error, it literally tells you what to do

Are you saying the bottom images of the folllowing figure which danadam said are spectral density are already Power Spectral Density? If so, why need separate Welch command? Unless the Welch command is doing not only averaging of chunks but also plotting nice smooth waveform of the average?

spectrum_vs_density.png



I actually googled about it all days ago. I read this:

reddit qoute.jpg


from
So even Welch is courser than FFT. What is better PSD than Welch?

About Matlab, Yes ".^" did it. However, I always encounter this error message the whole year and don't know what it means, although the code can run a figure (see bottom below). "Warning: Integer operands are required for colon operator when used as index. ". I guess Ill ask this to the matlab people. But since it still runs, I always ignore the warning message.

So it is true Octave defaults to power spectrum, while Matlab defaults to linear spectrum.

Something I still can't figure out for days. When doing power spectrum, you square the voltage. But when the voltage is 0.5 volts, the square becomes smaller like 0.25V. Shouldn't it be bigger since you square the voltage? The following is the figure when the .^ is used (power spectrum) in matlab:

matlab power spectrum.JPG



The following is the default Matlab linear spectrum (note the exponent 10^-4 of the following versus the power spectrum 10^-8 above which is smaller). So in power spectrum, the voltage which is squared becomes smaller? Then why call it power spectrum, shouldn't it be called inverse power spectrum?


matlab linear spectrum.JPG


I know these are questions to be asked elsewhere and not in audio forums. But let's just tie up the loose ends (or loose peaks), and I'll ask harder questions elsewhhere. Thank you.
 
Something I still can't figure out for days. When doing power spectrum, you square the voltage. But when the voltage is 0.5 volts, the square becomes smaller like 0.25V. Shouldn't it be bigger since you square the voltage? The following is the figure when the .^ is used (power spectrum) in matlab:

The following is the default Matlab linear spectrum (note the exponent 10^-4 of the following versus the power spectrum 10^-8 above which is smaller). So in power spectrum, the voltage which is squared becomes smaller? Then why call it power spectrum, shouldn't it be called inverse power spectrum?
This is basic arithmetics. Anything less than 1 becomes smaller when squared

0.5 squared is 0.25. Because 0.5 * 0.5 = 0.25
10^-4 squared is 10^-8. Because 0.0001 * 0.0001 = 0.00000001

Sorry I can't comment on other thing you wrote, you will need to figure this out yourself.
 
Is squaring has to do with the integral (with area hence need squaring see below) or is it because of the formula power = voltage² / resistance with power proportional to voltage square?
Both? With RMS you want to find DC voltage (signal) that has the same energy as AC voltage (signal). Energy is integral of power and power is proportional to V^2.

But is it not getting the power from V^2 is supposed to get bigger value?
No, why? Nowhere does it say that the number representing power has to be bigger than the number representing voltage.

But in the spectrum in the first 2 images (linear spectrum vs power spectrum). You get lower peak (10^-2) when getting the power spectrum (vs 10^-1 in linear spectrum), why is that??
Because the voltage is 0.1, so lower than 1, and like you said: "When you square a value less than 1 like 0.5, you get even smaller value like 0.25."

Another thing. How come in your Octave code you have to add the following to convert power spectrum to linear spectrum? But in Matlab there is no conversion.
Because "mag2" holds squared values. A few lines earlier there is:
Code:
    Y = 2 * abs(Y).^2 / win_s1^2;

    mag2 += Y;

If so, why need separate Welch command?
So it can be done in one line instead of a dozen. If you do:
Code:
[Y_welch, freqs_welch] = pwelch(X, win_coef, win_overlap, fft_size, Fs);
and plot "freqs_welch" and "Y_welch" then you'll get essentially (or maybe even exactly, I didn't check) the same result as plotting "freqs" and my power spectral density "Y = mag2 / enbw".
 
The signal is neither power nor linear spectrum. It's just signal. Those terms apply only to the result of FFT. You transform the results one way and you get power spectrum or you transform them another way and you get linear spectrum. Which one you choose depends on what you want to show or what you are interested in. Below is a single signal, let's say it is a recorded voltage. If you are interested in the voltage of the signal's components, then linear spectrum:
View attachment 478330
shows that 6k is 10 times larger than 12k. If you are interested in the power of the signal's components, then power spectrum:
View attachment 478331
shows that 6k has 100 times more power than 12k.


AFAIU:
  • spectrum is used when you are interested in peaks because (in spectrum) peaks' levels are not dependent on FFT size (and noise level is).
  • spectral density is used when you are interested in noise because (in spectral density) noise level is not dependent on FFT size (and peaks levels are).
The same signal on all graphs, spectrum on top, spectral density below:
View attachment 478335


It has one:

In your top image of the spectrum, is it in power spectrum or peak linear spectrum? In your code, its converted to peak linear spectrum. So, shouldn't it just be Vrms? why V^2 rms which is that of power spectrum? when displaying FFT, how would it appear if it is peak linear spectrum (if the top if power spectrum)? Pls show example of FFT of peak linear spectrum based on the above figures so same baseline.

Also why is spectral density peak amplitude smaller than the spectrum?

Last question. You said in spectral density, one focuses on the noises which are invariant to FFT size. Did you mean the noise floor? But some people seem to prefer PSD when dealing with broad peaks like the following. Any advantage in PSD for broad peak which is not noise at all?

broadband peak.jpg
 
In your top image of the spectrum, is it in power spectrum or peak linear spectrum?
It is power spectrum. The 32'768 length graph is the same as the one earlier in the post, where power spectrum is compared to linear spectrum.

In your code, its converted to peak linear spectrum.
That's just the default which I use most often but it is not what was used on those graphs. If I used the default, I would label the y-axis "V_peak".

In your code, its converted to peak linear spectrum. So, shouldn't it just be Vrms?
V_rms is different from peak linear spectrum. Peak is
Code:
% Convert from power spectrum [V_rms^2] to peak linear spectrum [V_peak]
Y = sqrt(mag2) * sqrt(2);
RMS is:
Code:
% Convert from power spectrum [V_rms^2] to linear spectrum [V_rms]
Y = sqrt(mag2);

why V^2 rms which is that of power spectrum?
The discussion earlier was about power spectral density and it made the most sense to me to compare it to power spectrum. So that's the conversion I used.

when displaying FFT, how would it appear if it is peak linear spectrum (if the top if power spectrum)? Pls show example of FFT of peak linear spectrum based on the above figures so same baseline.
There already is RMS linear spectrum earlier in the post, where power spectrum is compared to linear spectrum. Peak linear spectrum looks like RMS linear spectrum, only it is scaled by sqrt(2).

You said in spectral density, one focuses on the noises which are invariant to FFT size. Did you mean the noise floor?
Not only. I meant any noise-like signal.

But some people seem to prefer PSD when dealing with broad peaks like the following. Any advantage in PSD for broad peak which is not noise at all?
(Do you mean "which is not noise floor"?)

Probably would be better to ask those people.

I don't really focus on noise-like signals, so to me the only advantage is that FFT-size independence.
 
Back
Top Bottom