admin管理员组

文章数量:1122832

I'm working on plotting the Power Spectral Density (PSD) in MATLAB using loglog but I'm encountering an issue with the DC component (frequency = 0). Since log_10(0)= -inf MATLAB automatically excludes the DC component from the plot.

I tried assigning a small positive value to the DC frequency, and it works to include the component in the plot. However, this approach alters the true frequency values, which I want to avoid because it doesn't align with the actual spectrum. I also considered the "log-of-x-plus-one" transformation but it changes the real frequency axis and doesn’t reflect the true nature of the spectral data. My questions are:

  1. What are best practices for including the DC component in log-log spectral plots in MATLAB?

  2. Is there a way to represent the DC component (f=0) visually without assigning an arbitrary value that distorts the frequency axis?

  3. If the DC component is typically excluded, what’s the standard way to present or annotate it in such plots?

Any advice or insight on this would be greatly appreciated!

[PSD_u_mean, f_u_mean] = pwelch(detrend(nanmean(u,2)), hanning(WL), floor(WL/2), WL, FS);      
   
%%
figure;
loglog(f_u_mean, PSD_u_mean, 'LineWidth', 1.5); 
hold on

loglog( PSD_u_mean, 'LineWidth', 1.5); 
xlabel(' frequency')
ylabel(' PSD')
legend('With Correct Frequency', 'Using Indices Instead of Frequency');

本文标签: How to properly include the DC component in a MATLAB loglog plot for spectral analysisStack Overflow