day01

ts=0.5;
df=1.0;
fs = 20; %采样频率
n2 = 50/ts;
n1 = fs/df;
N = 2^(max(nextpow2(n1),nextpow2(n2)));
%当序列是2的幂次时,FFT算法高效
df = fs/N; %设置分辨率
t = 0:0.01:50;
y = 3sin(20pi*t+20);

Y2=fft(y,N); %使用FFT,计算离散傅立叶变换
Y2=Y2/fs;
f=[0:df:df*(N-1)]-fs/2; %调整频率坐标
subplot(2,2,4);
plot(f,fftshift(abs(Y2)),‘k’);
axis([-fs/2-0.5,fs/2+0.5,0,8*pi+0.5]);
title('快速傅立叶变换:\rm X_{s}(f) ');
xlabel(‘f’);

p66 习题2
https://www.wendangxiazai.com/b-c2b09366b84ae45c3b358cb5-3.html

https://wenku.baidu.com/view/23e7ad0776c66137ee061919.html
610

function sexpfr(alpha)
syms t mag phase
a = abs(alpha)
a=sqrt(2pi);
xt = exp(-t^2/2)/a;
ezplot(xt);
set(findobj(‘Type’,‘line’),‘Color’,‘k’)
title(’\rm F[e{-t2/2} /sqrt(2
pi)] ‘);
axis([-3,3,0,1]);
figure(2);
Xf=fourier(xt);
subplot(1,2,1);
ezplot(Xf);
set(findobj(‘Type’,‘line’),‘Color’,‘k’)
title(’\rm F[e{-t2/2} /sqrt(2pi)]幅度谱 ‘);
xlabel(‘f’);
subplot(1,2,2);
phase=atan(imag(Xf)/real(Xf));
ezplot(phase);
set(findobj(‘Type’,‘line’),‘Color’,‘k’)
title(’\rm F[e{-t2/2} /sqrt(2
pi)] 相位谱 ');
xlabel(‘f’);

function askdigital(s,f)
%本程序实现ASK 调制
%s——输入二进制序列,f——载波信号的频率
%调用举例:askdigital([1 0 1 1 0], 2)
t=0:2pi/99:2pi; %初始定义
cp=[];mod=[];bit=[];
for n=1:length(s); % 调制过程
if s(n)==0;
cp1=zeros(1,100);
bit1=zeros(1,100);
else s(n)==1;
cp1=ones(1,100);
bit1=ones(1,100);
end
c=sin(f*t);
cp=[cp cp1];
mod=[mod c];
bit=[bit bit1];
end

ask=cp.mod;
noise=rand(1,100); 
ask1=ask+noise;%加入噪声
subplot(2,1,1);
plot(bit,‘LineWidth’,1.5);grid on; %分别画出原信号、已调信号示意
ylabel(‘Binary Signal’);
axis([0 100
length(s) -2.5 2.5]);
subplot(2,1,2);
plot(ask,‘LineWidth’,1.5);grid on;
ylabel(‘ASK modulation’);
axis([0 100length(s) -2.5 2.5]);
subplot(2,1,3);
plot(bit,ask1,1.5); grid on;
ylabel(‘加入噪声的信号’);
axis([0 100
length(s) -2.5 2.5]);

function askdigital(s,f)
%本程序实现ASK 调制
%s——输入二进制序列,f——载波信号的频率
%调用举例:askdigital([1 0 1 1 0], 2)
t=0:2pi/99:2pi; %初始定义
cp=[];mod=[];bit=[];

for n=1:length(s); % 调制过程
if s(n)==0;
cp1=zeros(1,100);
bit1=zeros(1,100);
else s(n)==1;
cp1=ones(1,100);
bit1=ones(1,100);
end
c=sin(f*t);
cp=[cp cp1];
mod=[mod c];
bit=[bit bit1];
end

ask=cp.mod;
subplot(2,2,1);
plot(bit,‘LineWidth’,1.5);grid on; %分别画出原信号、已调信号示意
ylabel(‘Binary Signal’);
axis([0 100
length(s) -2.5 2.5]);
subplot(2,2,2);
plot(ask,‘LineWidth’,1.5);grid on;
ylabel(‘ASK modulation’);
axis([0 100length(s) -2.5 2.5]);
noise=rand(1,800);
ask1=(cp.mod+noise);
subplot(2,2,3);
plot(bit,‘LineWidth’,1.5);grid on; %分别画出原信号、已调信号示意
ylabel(‘Binary Signal’);
axis([0 100
length(s) -2.5 2.5]);
subplot(2,2,4);
plot(ask1,‘LineWidth’,1.5);grid on;
ylabel(‘ASK modulation 加噪声’);
axis([0 100
length(s) -2.5 2.5]);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值