what is power spectrum value mean ('pspectrum')

I used the following code.
This is a code that perform STFT on time series pressure data.
[p, f, t] = pspectrum(Pascal, sample_rate, 'TimeResolution', 1, 'spectrogram');
The MATLAB hompage explanation says the output('p') represents the power spectrum value.
I want to ask what is a power spectrum value's physical meaning, How is it related to my input, 'Pascal' ?
Thank you.

2 Comments

Hi @ 지,

p from pspectrum represents the power of your signal at each time–frequency point.Since your input is in Pascals (Pa), the power values are in Pa^2 — the squared pressure amplitude. Physically, it shows how much acoustic energy (pressure power) is present at each frequency and time.

Hope this helps!

thanks for your helpful answer.
But I wodner what calculations are applied on my input values(Pa).
DO you know the exact formula which is operated on input?

Sign in to comment.

 Accepted Answer

Hi @지호,

Thanks for your questions about the `pspectrum` function and how it processes your pressure data in Pascals. I’ve gone through your comments and prepared a detailed explanation that should clarify the calculations and physical meaning of the outputs.

1. Physical meaning of `p` from pspectrum You asked: “I want to ask what a power spectrum value's physical meaning is. How is it related to my input, 'Pascal'?”

When your input is in Pascals (Pa), `pspectrum` computes the *power spectrum*, which is in Pa^2 — that is, the squared pressure amplitude. Physically, it represents how much acoustic energy (pressure power) is present at each frequency and, for spectrograms, at each point in time.

2. What calculations are applied to the input You also asked: “I wonder what calculations are applied on my input values (Pa). Do you know the exact formula?”

The process is:

1. Segmentation: The signal is divided into overlapping segments. 2. Windowing: Each segment is multiplied by a Kaiser window to reduce spectral leakage. The shape of this window is controlled by the `Leakage` parameter. 3. FFT: The Fourier transform of each windowed segment is calculated. 4. Power calculation: The magnitude of the FFT is squared, normalized by the window energy, and scaled for one-sided spectra.

   * If your input is x(t) in Pa, the output is roughly:
     p(f,t) ≈ |FFT(x(t) * window)|^2 / window_energy

This ensures the output reflects the true physical power of your signal.

3. Questions about abs(fft(segment)) and dB

You asked: “Does `abs(fft(segment))` refer to the amplitude of the input data? Then where in the function manual is it written that `20*log10(abs(fft(segment)))` is applied?”

  • Yes, `abs(fft(segment))` gives the amplitude spectrum of the windowed segment.
  • In `pspectrum`, the power spectrum is *already squared*, so when plotting in decibels, it uses `10*log10(p)` instead of 20*log10.
  • The reference value (`pref`) for converting to dB isn’t explicitly required in `pspectrum` because it assumes the output is absolute power (Pa²). If you want to define dB relative to a standard reference, you can scale accordingly: `10*log10(p/pref^2)`.

4. Visualization via a .m file To make this concrete, I prepared a small MATLAB script that:

  • Performs the segmentation and windowing manually.
  • Computes the FFT and power spectrum for each segment.
  • Compares the manually computed spectrogram to `pspectrum`.

pspectrum_demo script

clear; close all; clc;
%% pspectrum_demo.m
% Illustrates how pspectrum processes pressure data
% Sample parameters
fs = 1000;                 % sample rate in Hz
t = 0:1/fs:1-1/fs;         % 1 second
x = 0.1*sin(2*pi*50*t) + 0.05*randn(size(t)); % example signal in Pa
% Parameters for STFT
segmentLength = 128;
overlap = 64;
window = kaiser(segmentLength,6); % Kaiser window similar to pspectrum
% Pre-allocate
nSegments = floor((length(x)-overlap)/(segmentLength-overlap));
p_manual = zeros(segmentLength/2+1, nSegments);
for k = 1:nSegments
  idx = (k-1)*(segmentLength-overlap) + (1:segmentLength);
  seg = x(idx).*window';
  xdft = fft(seg, segmentLength);
  p_seg = abs(xdft(1:segmentLength/2+1)).^2 / sum(window.^2);
  p_seg(2:end-1) = 2*p_seg(2:end-1); % one-sided scaling
  p_manual(:,k) = p_seg;
end
% Time vector for segment centers
t_seg = ((segmentLength/2):(segmentLength-overlap):(length(x)-    
segmentLength/2))/fs;
% Plot manual vs pspectrum
figure;
subplot(2,1,1)
imagesc(t_seg, (0:segmentLength/2)*(fs/segmentLength),   
10*log10(p_manual))
axis xy
xlabel('Time (s)'); ylabel('Frequency (Hz)');
title('Manual STFT Power (dB)');
subplot(2,1,2)
[p,f,t_ps] = pspectrum(x, fs, 'spectrogram', 'TimeResolution', segmentLength/
fs, 'OverlapPercent', overlap/segmentLength*100);
imagesc(t_ps, f, 10*log10(p))
axis xy
xlabel('Time (s)'); ylabel('Frequency (Hz)');
title('pspectrum Spectrogram (dB)');

The script produces two plots

1. Manual STFT Power (dB) – Shows how each segment contributes to the spectrogram, step by step. 2. pspectrum Spectrogram (dB) – Shows the built-in `pspectrum` result, which matches the manual computation.

This side-by-side comparison helps visualize how the input in Pascals becomes the power in Pa^2 and then optionally converted to decibels.

Plots: Please see attached.

In nutshell,

  • output of `pspectrum` represents squared pressure amplitude (Pa^2).
  • The computation follows: segmentation → windowing → FFT → magnitude squared → normalization.
  • Decibel conversion is `10*log10(p)`, not 20*log10, because it’s already power, not amplitude.
  • The `.m` file illustrates the calculations explicitly, making the process transparent.

Hope this helps clarify everything!

4 Comments

지호
지호 on 14 Nov 2025
Edited: 지호 on 14 Nov 2025
Thank you very much for your detail reply.
I learned a lot from reading your explanation.
However, the reason I originally asked about the physical meaning of the value was literally to understand what that numerical value represents in the real world.
Even though the output
p(f,t) ≈ |FFT(x(t) * window)|^2 / window_energy
It can be interpreted as meaning of power as you described, But this still includes FFT processing and windowing operations. So it doesn’t seem to represent exactly real-world acoustic power itself, right?
So what I want is not just some variable that loosely represents “power,” but the actual frequency-dependent power values – or, equivalently, the true squared acoustic pressure – that directly correspond to my input data (acoustic pressure).
This is because my real goal is to compute the frequency-dependent Sound Pressure Level (SPL) using (SPL) = 10log (P^2/(0.00002Pa)^2) formula.
Additionally, the description and examples of the pspectrum function only say that it returns 10 log10(p) only if the output variable [p, f, t] is not declared. Since my code explicitly specifies [p, f, t], I believe I need to manually perform the dB conversion after receiving the raw power output.
Thank you, I really appreciate it.

Hi @지호,

I went through your latest comments and everything you wrote including your shared link. You brought up very good points. Let me answer your points in the same order you brought them up so the whole picture stays consistent.

1. About the physical meaning of the pspectrum output

You pointed out that because pspectrum uses FFT + windowing, the output doesn’t feel like “real-world” acoustic power. That’s an understandable concern, but in MATLAB the FFT scaling and window normalization are handled specifically so that if your input is in pascals, the resulting power values still correspond to *Pa^2.

Windowing changes leakage and resolution, but it doesn’t destroy the physical units. So yes — the values represent real acoustic power as long as the input is real pressure.

2. You want the actual squared pressure for computing SPL

You mentioned that the reason you’re asking is because you ultimately need frequency-dependent SPL using

   10 log 10 * (P^2/(20*micro*Pa)^2)

Everything hinges on making sure P^2 s the true pressure-squared, not some normalized or relative value. You're absolutely right to check this carefully.

3. Your main question: Which pressure data should be used as input to pspectrum?

This was the most important part as shared in your link

https://www.mathworks.com/matlabcentral/answers/2181257-what-is-sound-pressure-level-spl-in-pspectrum-code?s_tid=srchtitle

“Which of the following values should be used as Pa_data so that the output can be converted into proper SPL values?”

The answer is unambiguous:Use the original, unmodified pressure signal in pascals. Not divided by 20 micro Pa, not normalized, not squared, not RMS-scaled.Just the raw pressure time series in Pa.

pspectrum assumes the input carries the physical unit. If the input is Pa, the output is directly in terms of Pa² (or Pa²/Hz for PSD). That’s exactly what SPL calculations need.

Any pre-scaling you do (for example, dividing by 20 micro Pa) breaks the physical meaning of the spectral output.

4. About the “pspectrum doesn’t return dB when I specify [p,f,t]”

You’re right. When you capture the outputs explicitly, MATLAB returns linear power, not dB. You must apply the dB or SPL conversion manually afterward. That’s the expected behavior.

5. Final point about “real-world” vs windowed/FFT values

Even though pspectrum passes through FFT and windowing, the normalization makes sure that the total spectral power matches the time-domain power (Parseval’s theorem). So as long as the input is in Pa, the values are consistent with real acoustic pressure squared.

So, the bottom line is:

  • Input to pspectrum must be the raw pressure in Pa.
  • Then convert the output to SPL using
            10 log 10 * (P^2/(20*micro*Pa)^2)

This gives physically meaningful SPL.

Please let us know if you need further assistance or help.

Thank you sir. But I asked mathwork service center, then they said the out put is not a literally acoustic power itself. It is a just processed number which is related to real power. But I was really impressed about your answer.

Hi @지호,

Thank you for the clarification! That makes sense — if the MathWorks service team said the output isn’t the literal acoustic power but rather a processed or related value, then that explains the difference. I really appreciate you checking and letting me know. And thank you for the kind words — I’m glad my explanation was helpful!

Sign in to comment.

More Answers (1)

@지호. The documentation of pspectrum illustrates that the calculation processes to construct the spectrogram of a nonstationary signal follows these steps:
  1. Divide the signal into equal-length segments. The segments must be short enough that the frequency content of the signal does not change appreciably within a segment. The segments may or may not overlap.
  2. Window each segment and compute its spectrum to get the short-time Fourier transform.
  3. Use the segment spectra to construct the spectrogram:
  • If called with output arguments, concatenate the spectra to form a matrix.
  • If called with no output arguments, display the power of each spectrum in decibels segment by segment. Depict the magnitudes side-by-side as an image with magnitude-dependent colormap.
Accroding to the above explanation, the power spectrum value is the power of spectrum in decibels, which can be expressed as , where segment represents segmented time series signal.

1 Comment

Thank you for your helpful answer. Can you answer a few more related questions?
1. Does abs(fft(segment)) refer to the amplitude of the input data? , Then where in the function manual is it written that 20log[abs(fft(segment)) ] is applied?
2. I think there should be a section that provides deviding reference value (pref) when calculating decibels.
Is there a section for that?
Thank you again for your answer.

Sign in to comment.

Asked:

on 12 Nov 2025

Commented:

on 18 Nov 2025

Community Treasure Hunt

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

Start Hunting!