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)
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?
You need to multiply by half the sampling rate. I.e., the normalized frequency "1.0" is Fsample/2.
For a simple example, here's a 200 Hz signal sampled at 4KHz:
x=sin(2*pi*200/4000*[0:1000])
Running pmusic(x, 2)
gives a pronounced peak at the normalized frequency 0.1.
Converted to Hz, this is 0.1*4000/2 = 200 Hz.
I have modified your function to make it easier to analyze (just one sine function and no randomness):
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);
To get better resolution use pmusic(x,2,[0:.01:0.2])
.