what is power spectrum value mean ('pspectrum')

59 views (last 30 days)
지호
지호 on 12 Nov 2025 at 3:15
Commented: Umar on 18 Nov 2025 at 17:36
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
Umar
Umar on 12 Nov 2025 at 6:51

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!

지호
지호 on 14 Nov 2025 at 8:17
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

Umar
Umar on 14 Nov 2025 at 9:34

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 18 Nov 2025 at 8:39

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.

Umar
Umar on 18 Nov 2025 at 17:36

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)

Chuguang Pan
Chuguang Pan on 12 Nov 2025 at 7:14
@지호. 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
지호
지호 on 14 Nov 2025 at 9:06
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.

Community Treasure Hunt

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

Start Hunting!