?? qam.m
字號:
function[y,fs,fb,fc] =qam(x,Kbase,fs,fb,fc);
%Usage:[y,fs,fb,fc] =qam(x,Kbase,fs,fb,fc); BBI 2000
if nargin<5;fc=2; end;
if nargin<4;fb=1; end;
if nargin<3;fs=32; end;
if nargin<2;Kbase=2; end;
if nargin<1;
x=[1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 0];
x=[x 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0];
x=[x 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0];
x=[x 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 0];
end;
T=length(x)/fb; m=fs/fb; nn=length(x);
dt=1/fs; t=0:dt:T-dt;
Kbase=rem(Kbase,2); Kbase=Kbase+(Kbase==0)*2; tstr='QAM';
I=x(1:2:nn-1); [I,In]=two2four(I,4*m);
Q=x(2:2:nn); [Q,Qn]=two2four(Q,4*m);
if Kbase==2;
I=bshape(I,fs,fb/4); Q=bshape(Q,fs,fb/4);
end;
y=I.*cos(2*pi*fc*t)-Q.*sin(2*pi*fc*t);y1=y;
n=length(y);
if nargout<1;
%subplot(211);
figure(1);
plot(t,y,[0 T],[0 0],'b:')
figure(2);
plot(t,I);
figure(3);
plot(t,Q);
%,t,I,t,Q,[0 T],[0 0],'b:');
%plot(t,y,t,I,t,Q,[0 T],[0 0],'b:');
if Kbase==2;
tstr=[tstr 'with the RC filter'];
end; 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;
figure(4);
plot(f,y,'r'); grid on;
Title('spectrum'); xlabel('f/fb'); zoom xon;
figure(5);
constel(y1,fs,fb,fc); xlabel('Constellation');
set(gcf,'num','off','name',[tstr ',' blanks(10) '曾晶']);
end;
%Start SystemView Definition ---------------
%SVU nInputs=1;
%SVU InputCaption0='In0';
%SVU nOutputs=1;
%SVU OutputCaption0='Out0';
%SVU nParameters=1;
%SVU ParameterCaption0='Param0';
%SVU FunctionSyntax='[Out0] = qam(In0,Param0);';
%End SystemView Definition -----------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -