求MATLAB仿真程序

2024-11-06 08:15:28
推荐回答(1个)
回答1:

clear all;
g=[1 0 1 1 1 0 0 1];%基带信号
f=100; %载波频率
t=0:2*pi/99:2*pi;
cp=[];sp=[];
mod=[];mod1=[];bit=[];
for n=1:length(g);
if g(n)==0;
die=-ones(1,100); %Modulante
se=zeros(1,100); %
else g(n)==1;
die=ones(1,100); %Modulante
se=ones(1,100); %
end
c=sin(f*t);
cp=[cp die];
mod=[mod c];
bit=[bit se];
end
bpsk=cp.*mod;
subplot(2,1,1);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal');
axis([0 100*length(g) -2.5 2.5]);
subplot(2,1,2);plot(bpsk,'LineWidth',1.5);grid on;
title('ASK modulation');
axis([0 100*length(g) -2.5 2.5]);