Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to change color and Line property in Pwelch

2,274 views
Skip to first unread message

Frank Sun

unread,
Apr 12, 2007, 5:49:48 PM4/12/07
to
Hi I am using pwelch to plot the power spectral density for multiple
sets of data and I want to plot all of them on one figure. However I
can't figure out how to change color for each plot or line properties
such that I can distinguish between the data. I tried the 'hold'
command

hold all;
pwelch(data1);
pwelch(data2);

but this has two PSD with the same color, i don't know which is
which!!!

Any help is greatly appreciated!!!!

Gideon Prior

unread,
Oct 18, 2009, 10:18:01 PM10/18/09
to
Have you figured this out? I am now having the same problem. Thanks


"Frank Sun" <fran...@mail.utexas.edu> wrote in message <ef53f...@webcrossing.raydaftYaTP>...

Gideon Prior

unread,
Oct 18, 2009, 10:19:01 PM10/18/09
to
Have you figured this out? I am now having the same problem. Thanks


"Frank Sun" <fran...@mail.utexas.edu> wrote in message <ef53f...@webcrossing.raydaftYaTP>...

Johan

unread,
Nov 19, 2009, 4:11:03 AM11/19/09
to
I had the same problem and i solved it by plotting the output from the pwelch function myself, like this:

[Pxx1 F1] = pwelch(x1,[],[],[],fs);
Pxx1dB = 10*log10(Pxx1);
semilogx(F1,Pxx1dB,'r')
hold on
[Pxx2 F2] = pwelch(x2,[],[],[],fs);
Pxx2dB = 10*log10(Pxx2);
semilogx(F2,Pxx2dB)
hold off
grid on

For some reason the x-axis limits are a bit to high, so you might want to adjust the axis like:
axis([min(F2) max(F2) min(Pxx2dB) max(Pxx2dB)])

It might not be as short as one would like, but it works =)

R T

unread,
Dec 9, 2010, 6:42:05 PM12/9/10
to
I solved the problem:

figure;
NFFT = 2^nextpow2(length(d));
Pdd = abs(fft(d,NFFT)).^2/length(d)/Fs;
Pee = abs(fft(e,NFFT)).^2/length(e)/Fs;
PSD_d = dspdata.psd(Pdd(1:length(Pdd)/2),'Fs',Fs);
PSD_e = dspdata.psd(Pee(1:length(Pee)/2),'Fs',Fs);
hold on
h1 = plot(PSD_d);
set(h1,'Color','b');
h2 = plot(PSD_e);
set(h2,'Color','r');
hold off

Esti

unread,
Jul 20, 2012, 3:14:13 AM7/20/12
to
Click the "show plots tool and dock figure" icon on the figure window. Then you can choose the color of each line by selecting the available color by using mouse. There are also other useful setting there.
If you want to display the legend, click show legend icon and change the data set name by using command window (here is the code: legend('datasetname1','datasetname1',...))

Keek

unread,
Jul 8, 2015, 2:40:09 AM7/8/15
to
If the color itself is not necessary, but just become different try:

pwelch([data1,data2]);

regards
Keek

"Frank Sun" <fran...@mail.utexas.edu> wrote in message <ef53f...@webcrossing.raydaftYaTP>...
0 new messages