how to get real frequency components using MUSIC compute frequency?

I used pmusic ( https://au.mathworks.com/help/signal/ref/pmusic.html ). It seems that pmusic cannot get real frequency for the signal.
x = cos(0.257*pi*n) + sin(0.2*pi*n) + 0.01*randn(size(n))
should have frequency components of 0.1258 and 0.1.
1. pmusic with No Sampling Specified example
But, the peaks for x-axis(normalized frequency) are 0.257 and 0.2.
2. Specifying Sampling Frequency and Subspace Dimensions example
But, the peaks for x-axis( frequency) are 812(=0.2*fs/2) and 1258(=0.257*fs/2) .
It seems that pmusic cannot get real frequency for the signal? So the peaks at x-axis is not the real frequency? what is the actually frequency? how could I get them for pmusic

4 Comments

I just use the same code as the example in the webpage.
Specifying Sampling Frequency and Subspace Dimensions
rng default
n = 0:199;
x = cos(0.257*pi*n) + sin(0.2*pi*n) + 0.01*randn(size(n));
[P,f] = pmusic(x,[Inf,1.1],[],8000,7); % Window length = 7
plot(f,20*log10(abs(P)))
xlabel 'Frequency (Hz)', ylabel 'Power (dB)'
title 'Pseudospectrum Estimate via MUSIC', grid on
pmusic with No Sampling Specified
n = 0:199;
x = cos(0.257*pi*n) + sin(0.2*pi*n) + 0.01*randn(size(n));
pmusic(x,4) % Set p to 4 because there are two real inputs
When you pass fs of 8000 into the first pmusic() call, you are lying completely about the sampling frequency.
thanks for reply.
how should I set the fs for the first pmusic call?
x = cos(0.257*pi*n) + sin(0.2*pi*n) + 0.01*randn(size(n)) have frequency components of 0.1258 and 0.1.
when I set fs= 2*0.1258=0.257, the result of frequency still seems not right?
rng default
n = 0:199;
x = cos(0.257*pi*n) + sin(0.2*pi*n) + 0.01*randn(size(n));
[P,f] = pmusic(x,[Inf,1.1],[],0.257,7); % Window length = 7
plot(f,20*log10(abs(P)))
xlabel 'Frequency (Hz)', ylabel 'Power (dB)'
title 'Pseudospectrum Estimate via MUSIC', grid on

Sign in to comment.

Answers (1)

rng default
n = 0:199;
f1 = 0.257/2; f2 = 0.2/2;
fs= 2; % fs (fs>2*max(f1, f2)
% generate signal according to f1, f2, fs
t = n/fs;
x = cos(f1*2*pi*t) + sin(f2*2*pi*t) + 0.01*randn(size(t));
nfft=1024;
[P,f] = pmusic(x,4,nfft,fs,7); % Window length = 7
plot(f,20*log10(abs(P)))
xlabel 'Frequency (Hz)', ylabel 'Power (dB)'
title 'Pseudospectrum Estimate via MUSIC', grid on
xline([f1 f2])

4 Comments

thanks for reply.
but when I choose fs to 3, the frequencies (f1, f2) in the figure below are still not right?
rng default
n = 0:199;
f1 = 0.257/2; f2 = 0.2/2;
fs= 3; % fs (fs>2*max(f1, f2)
% generate signal according to f1, f2, fs
t = n/fs;
x = cos(f1*2*pi*t) + sin(f2*2*pi*t) + 0.01*randn(size(t));
nfft=1024;
[P,f] = pmusic(x,4,nfft,fs,7); % Window length = 7
plot(f,20*log10(abs(P)))
xlim([0 1])
xlabel 'Frequency (Hz)', ylabel 'Power (dB)'
title 'Pseudospectrum Estimate via MUSIC', grid on
xline([f1 f2])
You have a too small window size, which results in poor resolution. It could not resolve the two freq (when fs increase, the two freq normalized by fs get closer). To increase the resolution, you can increase the windown length (say 16).
rng default
n = 0:199;
f1 = 0.257/2; f2 = 0.2/2;
fs= 3; % fs (fs>2*max(f1, f2)
% generate signal according to f1, f2, fs
t = n/fs;
x = cos(f1*2*pi*t) + sin(f2*2*pi*t) + 0.01*randn(size(t));
nfft=1024;
[P,f] = pmusic(x,4,nfft,fs,16); % Window length = 7
plot(f,20*log10(abs(P)))
xlim([0 1])
xlabel 'Frequency (Hz)', ylabel 'Power (dB)'
title 'Pseudospectrum Estimate via MUSIC', grid on
xline([f1 f2])
thanks for your reply.
how to choose a proper fs and window length?
when I set fs to 0.4, what is the proper window length?
Fs should be at least 2x of the max freq of interest to satisfy the sampling requirement.
Window length should be long enough to resolve the frequencies. For conventional method using FT to estimate spectrum, L is proportial to fs/delta_f. For the example above:
f1 = 0.257/2; f2 = 0.2/2;
fs= 3;
% Length of windows for conventional FT
fs/abs(f2-f1)
ans = 105.2632
For MUSIC, the windown length can be significantly smaller. The exact number is subject to SNR, noise properties, signal properties and so on (since signal and noise subspaces are estimated from the data).

Sign in to comment.

Asked:

on 26 Nov 2023

Commented:

on 30 Nov 2023

Community Treasure Hunt

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

Start Hunting!