4

suppose that we have following code

function [ x ] = generate1(N,m,A3)
f1 = 100;
f2 = 200;
T = 1./f1;
t = (0:(N*T/m):(N*T))'; %'
wn = randn(length(t),1); %zero mean variance 1
x = 20.*sin(2.*pi.*f1.*t) + 30.*cos(2.*pi.*f2.*t) + A3.*wn;
%[pks,locs] = findpeaks(x);
 plot(x)
end

i have generated signal using following command

y=generate1(3,500,1);

and i have got 501 length sample,now i want to use music method to detect frequencies,namely 100 and 200,assume that number of parameter is 2,so i have tried

pmusic(y,4)

enter image description here

how determine actually frequencies from this picture?i think that i need to convert a from normalized frequency to actual frequency,as i know normalized frequency is same as $f/f_s$ where $f_s$ is sampling frequency,but in this case what i should do?

4

1 回答 1

4

您需要乘以采样率的一半。即,归一化频率“1.0”是Fsample/2。

举个简单的例子,这是一个以 4KHz 采样的 200Hz 信号:

x=sin(2*pi*200/4000*[0:1000])

运行pmusic(x, 2)在归一化频率 0.1 处给出明显的峰值。转换为 Hz,即 0.1*4000/2 = 200 Hz。

我已经修改了您的函数以使其更易于分析(只有一个正弦函数,没有随机性):

 function x = gen(N,m)
    f1 = 100;
    T  = 1/f1;
    dt = N*T/m;

    x = sin(2*pi*f1*dt*[0:num_of_samples]);
 end

 x = gen(3,500,1e3);

为了获得更好的分辨率,请使用pmusic(x,2,[0:.01:0.2]).

于 2014-02-16T14:51:18.183 回答