How can I save a plot made using pwelch (power spectral density) command

4 views (last 30 days)
So, I'm using this command to generate a power spectral density plot:
pwelch(a(1:1843200),hanning(1024*8),0,1024*8,512);
but this returns a window and I was wondering if I could write another line of code which is going to save this image automatically.
Furthermore, when I set
X= pwelch(a(1:1843200),hanning(1024*8),0,1024*8,512);
and do plot(x) it does not give me the plot with power and frequency on the axis. Is there a way of solving that?
Any help will be appreciated guys!

Answers (1)

Walter Roberson
Walter Roberson on 26 Aug 2015
[X, f] = pwelch(a(1:1843200),hanning(1024*8),0,1024*8,512);
plot(f, 10*log10(X));
xlabel('Frequency (Hz)')
ylabel('Magnitude (dB)')
saveas(gcf, 'MyPwelch.jpg');

Community Treasure Hunt

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

Start Hunting!