早教吧 育儿知识 作业答案 考试题库 百科 知识分享

英语翻译t=0:.001:.25;x=sin(2*pi*50*t)+sin(2*pi*120*t);y=x+2*randn(size(t));plot(y(1:50))title('Noisytimedomainsignal')Y=fft(y,256);Pyy=Y.*conj(Y)/256;f=1000/256*(0:127);plot(f,Pyy(1:128))title('Powerspectraldensity')xlabel('F

题目详情
英语翻译
t = 0:.001:.25;
x = sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t));
plot(y(1:50))
title('Noisy time domain signal')
Y = fft(y,256);
Pyy = Y.*conj(Y)/256;
f = 1000/256*(0:127);
plot(f,Pyy(1:128))
title('Power spectral density')
xlabel('Frequency (Hz)')
▼优质解答
答案和解析
t = 0:.001:.25;%%%产生时间序列t,隐含采样率f=1/0.001=1000Hz
x = sin(2*pi*50*t) + sin(2*pi*120*t);%%产生时域信号,有50Hz和120Hz两个频率
y = x + 2*randn(size(t));%%给x加噪声,randn的用法不用说了吧
plot(y(1:50))%%作图
title('Noisy time domain signal')
Y = fft(y,256);%%%对时域加噪信号做256点傅里叶变换
Pyy = Y.*conj(Y)/256;%%求个频率点处幅值
f = 1000/256*(0:127);%%频率轴
plot(f,Pyy(1:128))
title('Power spectral density')
xlabel('Frequency (Hz)')
你的频率分辨率df=1000/256=3.9Hz,不合适,无法分辨出50Hz和120Hz,望注意.
希望对你有所帮助,有问题欢迎追问,满意请采纳.
给你一个参考程序:
Fs=50;%%采样频率
N=100;%%采样点数
dt=1/Fs;%%时域最小间隔,即时域分辨率
t=(0:N-1)*dt;%%采样时间长度
df=Fs/N;%%频域最小间隔,即频域分辨率
f=(-N/2:N/2-1)*df;
x=sin(2*pi*15*t)+2*sin(2*pi*18*t);
y=fft(x);
Y=fftshift(y);
A=abs(Y);
A=A/(N/2);%%还原真实幅值
figure(1)
subplot(121)
plot(t,x)
xlabel('时间t')
ylabel('幅值x')
grid on
subplot(122)
plot(f,A)
xlabel('频率f')
ylabel('幅值A')
grid on
看了 英语翻译t=0:.001:....的网友还看了以下: