In MATLAB I can't seem to figure out how to get the dspdata.psd function to display my power spectral density plot in Hz instead of kHz for the x-axis. If anyone knows a solution it would be greatly appreciated, thank you!
Change psd plot to display frequency in Hz instead of kHz
1.4k views Asked by Vincent At
2
There are 2 answers
0
On
I'm not familiar with the dspdata.psd
function, but you can directly change it on the figure after you plot it by:
ax = gca();
for i=1:numel(ax.Children)
ax.Children(i).XData = ax.Children(i).XData*1000;
end
ax.XLabel.String = 'Frequency [Hz]';
Note, that I'm using Matlab 2014b - if you are using an older version, you might not have access to ax.Children the same way in that case you can do it like this:
ax = gca();
data = get(ax,'Children');
for i=1:numel(data)
set(data(i),'XData', get(data(i),'XData')*1000);
end
set(get(ax,'XLabel'),'String','Frequency [Hz]');
You may change the axis scale from the figure properties(Show Plot Tools and Dock Figure) option. In the X Axis tab, you can modify the X Limits to Hz from KHz.