用matlab实现功率谱

问题描述:

用matlab实现功率谱
%随机产生1000个信号
clf;
n=1000;
a=randint(1,n); %随机信号
s2=round(a);
signal=[];
s3=(ones(1,1200))'*s2; %抽样
signal=s3(:)';
figure(1);
subplot(311);
plot(signal);axis([0,12000,-0.1,1.1]);grid on;title('随机信号的二进制');
%画出信号为0时的波形
fs=12;%采样频率
fc=1;%载波频率
Tc=1/fc;%载波周期
N0=10;
T=N0*Tc;
Ts=Tc/fs;%采样间隔
t=0:Ts:(T-Ts);%信号为0时的时间宽度 画图时前一个波和后一个波的关系.
A=0.1;
B=0.1;
y0=A*sin(2*pi*fc*t);%信号为0时的波形
figure(2)
subplot(211);
plot(t,y0);%画出信号为零时的波形
title('比特0的信号')
%画出信号为1时的波形
N1=10;
N2=N0-N1;
M=pi;
t11=0:Ts:(N1*Tc-Ts);
y11=B*sin(2*pi*fc*t11+M);
t12=0:Ts:(N2*Tc-Ts);
y12=A*sin(2*pi*fc*t12);
y1=[y11,y12];
figure(2)
subplot(212);
plot(t,y1)%画出信号为1时的波形
title('1的比特信号')
%画出随机产生的10个信号的调制波形
c=[];
for i=1 :n
if (a(i)==0);
c=[c y0];
else
c=[c y1];
end
end
tt=0:Ts:(n*T-Ts);
figure(1)
subplot(312);
plot(tt,c);
title('ebpsk调制随机信号的波形');
axis([0,100,-0.2,0.2]);
1个回答 分类:综合 2014-10-20

问题解答:

我来补答
n=0:0.1:200;%设定信号时间长度为0到200秒,采样间隔0.1,则采样频率为10HZ,点数2001
y=sin(2*pi*0.2*n)+sin(2*0.213*n);
Y=fft(y);%FFTPyy=Y.*conj(Y)/2000;%信号功率谱f=10*(0:1000)/2000;%计算横轴频率值figure(1)subplot(2,1,1),plot(n,y),title('信号'),xlabel('时间(S)')subplot(2,1,2),plot(f,Pyy(1:1001)),title('信号功率谱'),xlabel('频率(Hz)')
请采纳答案,支持我一下.
 
 
展开全文阅读
剩余:2000
上一页:为什么只选B
下一页:第8题练习