frequency spectrum using fft function

1 次查看(过去 30 天)
enas
enas 2012-1-2
is the code is right for a question :
compute the frequency spectrum using fft function (512 points) and generate a 4_by_2 plot such as :
the first column displays the window function in time domain 0<=n<=M-1 , the second column displays the window function in frequency domain with the correct frequency scaling in [0,fs/2].
consider a sinusoidal mixture x(n) given as:
x(n)=A1sin(w1nTs+O1)+A2sin(w2nTs+O2)+v(n)
where A1=0.1,A2=1,w1=20.1,w2=20.15,Ts=1,O1,O2 distributed between [0,2ᴨ],v(n)is a zero-mean white Gaussian noise process of variance Q^2=0.01.
clear,clc,close all
% _ _ signal generation
A1= 0.1; % Amplitude 1
A2= 1; % amplitude 2
w1= 2*pi*0.1; % angular frequency 1
w2= 2*pi*1; % angular frequency 2
Ts= 1; % sampling time
N= 512; % no. of process samples to be generated
K= ; % no. of independent process realization
sgm= ; % standard deviation of the noise
n=repmat([0:N-1].',1,k)
phi1=repmat(rand(1,k)*2*pi,N,1) ; % random phase matrix 1
phi2=repmat(rand(1,k)*2*pi,N,1) ; % random phase matrix 2
x=A1*sin(w1*n*Ts+phi1)+A2*sin(w2*n*Ts+phi2)+sgm*randn(N,k) ; % resulting signal

回答(1 个)

Rick Rosson
Rick Rosson 2012-1-3
It looks like you have a good start. Here are some additional functions that will help complete the assignment:
>> doc fft
>> doc fftshift
>> doc abs
>> doc log10
>> doc rand
>> doc randn
>> doc figure
>> doc subplot
>> doc plot

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by