Hi Haru,
From what I gather, you want to figure out how the time width of the Kaiser window is determined with the “pspectrum” function in MATLAB.
For this, you can go through the following steps and the relevant code snippets:
1. Create the spectrogram plot using the “pspectrum” function with the specified parameters.
W_mix = rand(1, 15000); % Example waveform data
Fs = 1e8;
FrequencyResolution = 9e4;
% Calculate the spectrogram and plot it
pspectrum(W_mix, Fs, 'spectrogram', ...
'FrequencyLimits', [0 1.2e6], ...
'FrequencyResolution', FrequencyResolution, ...
'Overlap', 99, ...
'Leakage', 0.75, ...
'MinThreshold', -95);
2. Retrieve the handle to the current spectrogram plot using “gca” function and extract the time vector from the plot’s children.
h = gca;
spectrogramData = h.Children;
timeVector = spectrogramData.XData;
3. Then determine the length of time window by taking the difference between the first and last points of time vector and dividing by the length.
% Calculate the time width of the window
windowLength = length(timeVector); % Length of the time window
timeWidth = (timeVector(end) - timeVector(1)) / windowLength;
Refer to the output below for more clarity:

For more information on “gca” function and graphic objects in MATLAB, you may refer to the following documentations:
- https://www.mathworks.com/help/matlab/ref/gca.html
- https://www.mathworks.com/help/matlab/creating_plots/graphics-objects-overview.html
I hope this is helpful.