ask.m
来自「交全面的给出了好几种调制解调方案的matlab代码,又ASK,BPSK,FSK,」· M 代码 · 共 26 行
M
26 行
function [y,fs,fb,fc]=ask(x,Kbase,fs,fb,fc);
%
% Usage: [y,fs,fb,fc]=ask(x,Kbase,fs,fb,fc);BBI 2000;fc为载波频率其中又缺省参数if nargin<5; fc=2;end;
if nargin<4; fb=1; end;
if nargin<3; fs=32; end;
if nargin<2; Kbase=1; end;
if nargin<1; x=[0 0 1 1 1 0 0 1 0 1 1 0 0 0 1 0]; end;
T=length(x)/fb;m=fs/fb;
dt=1/fs; t=0:dt:T-dt;
xx=pulse(x,m,2);
if Kbase==2; xx=bshape(xx);end;
y=(xx>=0).*sin(2*pi*fc*t); % ASK or OOK
%--------------------------------------------------------------------------
if nargout<1;
subplot(211);plot(t,y,t,xx*.5,[0 T],[0 0],'b:');axis([20,44,-1,1]);
title('Signal');
n=length(y);y=fft(y)/n;y=abs(y(1:fix(n/2)))*2;
I=find(y<1e-04);y(I)=1e-04;y=20*log10(y);
f1=m/n;f=0:f1:(length(y)-1)*f1;
subplot(212);plot(f,y,'r');grid on;
title('Spectrum');xlabel('f/fb');zoom xon;
set(gcf,'num','off','name',['ASK(OOK)','blanks(10)','BBI 2000']);
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?