?? bpsk_code.m
字號:
function bpsk_output=bpsk_code(code_input,frequency)
% Modulation BPSK
% bpsk_output is output of BPSK modulation
% code_input is a sequence of digital signal
% frequency is carrier frequency
% Author is lipeng
% date:2008 11 15
% Example:
% bpsk_output=bpskd_code([1 0 1 1 0],2)
% code_input=[1 0 1 1 0 1 0 1 0 0 0 1 1 0 1];
% frequency=2;
% nargin=2;
clc;
if nargin > 2
error('Too many input arguments');
elseif nargin==1
frequency=1;
elseif nargin==0
code_input=[1 0 1 1 0 1 0 1 0 0 0 1 1 0 1];
frequency=1;
end
if frequency<1;
error('Frequency must be bigger than 1');
end
t=0:2*pi/(100*frequency-1):2*pi;
cp=[];
sp=[];
mod=[];
mod1=[];
bit=[];
for n=1:length(code_input);
if code_input(n)==0;
die=-ones(1,100*frequency); %Modulante
se=zeros(1,100*frequency);
else code_input(n)==1;
die=ones(1,100*frequency); %Modulante
se=ones(1,100*frequency);
end
c=sin(frequency*t);
cp=[cp die];
mod=[mod c];
bit=[bit se];
end
bpsk_output=cp.*mod;
subplot(8,1,1);
plot(bit,'LineWidth',1.5);
grid on;
title('Binary Signal');
axis([0 100*length(code_input)*frequency -2.5 2.5]);
subplot(8,1,2);
plot(bpsk_output,'LineWidth',1.5);
grid on;
title('BPSK modulation');
axis([0 100*length(code_input)*frequency -2.5 2.5]);
%save 'bpsk_date.mat' bpsk_output;
%save 'bpsk_frequency' frequency;
clc;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -