plot multiple PSD lines in single graph in color scale (imagesc)

Hi, I have 13 signals where I produce the PSD for each with the psd function using Welch's method object (spectrum.welch). But this only allows me to generate separate plots for each signal. Is there a way to express all 13 PSDs in pseudocolor (like imagesc) in a single figure where Y is each of the 13 signals, X is the frequencies, and the color is the power/frequency (dB/Hz)? So basically I want to generate a 13 x n matrix containing the PSD of each signal.
Example:
Fs=10000; %sampling frequency in samples per second
t=0:(1/Fs):1; %one second time vector, 10001 elements
y=0.4*cos(2*pi*2000*t)+0.2*sin(2*pi*1000*t)+randn(size(t));
h = spectrum.welch;
Hpsd=psd(h,y,'Fs',Fs,'ConfLevel',0.95);
figure, plot(Hpsd)
This only gives me 1 plot. If I do this 13 times, how can I create a 13 x n figure where the PSDs are expressed in color? I basically want a figure that looks like imagesc(rand(13,100)) but with PSDs and not random numbers.
Thanks in advance!

 채택된 답변

Youssef  Khmou
Youssef Khmou 2014년 1월 11일
편집: Youssef Khmou 2014년 1월 11일
Yes you can generate the 2D spectrum, here is an example with 13 signals as you said :
Fs=80;
f=10+rand(13,1)*10; % frequencies of the signals
t=0:1/Fs:10-1/Fs;
y=zeros(13,length(t));
for n=1:13
y(n,:)=sin(2*pi*t*f(n));
end
% spectrum
h=spectrum.welch;
F=zeros(13,129);
for n=1:13
t=psd(h,y(n,:),'Fs',Fs);
F(n,:)=t.Data;
end
figure, surface(F), shading interp
You add the x,y labels...

댓글 수: 3

Thanks for the response. Although this certainly does give me a 2D spectrum, I'm a bit confused by the units in the vector of the data within dspdata. For example, in the above example for one of the iterations (say n=1), if you just plotted t ("plot(t)"), the units are in dB/Hz and range from -70 to 0. But the units are different from the nth vector in F where the values range ~e-9 to ~0.3. What are the units of F? Is there a way to plot the spectrum in dB/Hz, aka express F in dB/Hz?
I figured it out. I just need to multiply F by 10*log10 and the units become dB/Hz.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 1월 11일

0 개 추천

Perhaps the waterfall() function?

카테고리

도움말 센터File Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

질문:

S
S
2014년 1월 10일

댓글:

2014년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by