Why does the PERIODOGRAM function give no output when used

Illustration
Quincy - 2021-03-15T10:07:13+00:00
Question: Why does the PERIODOGRAM function give no output when used

Why does the PERIODOGRAM function give no output when used with the SUBPLOT function in Signal Processing Toolbox 6.2 (R14)? I have two data sets for which I want periodograms. When I try to plot them in the same figure using SUBPLOT, I obtain two empty axes. I used the following code:       x1=rand(1,100); x2=rand(1,100); subplot(2,1,1) periodogram(x1); subplot(2,1,2) periodogram(x2);  

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

The periodogram function in MATLAB might give no output for several reasons. Here are a few common issues and solutions:

  1. Empty Input Signal: Ensure that your input signal x is not empty. If the signal is empty, the periodogram function will not produce any output.

  2. Incorrect Axes: If you're using subplot to plot multiple periodograms, make sure you're specifying the correct axes. Sometimes, the axes might not be properly initialized.

  3. Data Type Issues: Verify that the input signal is of a compatible data type (e.g., double or single). If the data type is not supported, the function might fail silently.

  4. Window and FFT Parameters: Check the parameters for the window and FFT (e.g., window, nfft). Incorrect parameters can lead to unexpected results or no output.

Example Code

Here's an example of how to use the periodogram function correctly:

matlab
% Generate a sample signal
fs = 1000; % Sampling frequency
t = 0:1/fs:1-1/fs;
x = sin(2*pi*50*t) + 0.5*randn(size(t)); % Signal with noise

% Compute the periodogram
[pxx, f] = periodogram(x, [], [], fs);

% Plot the periodogram
figure;
plot(f, 10*log10(pxx));
title('Periodogram of the Signal');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!