求基于MATLAB的通信原理课程设计
脉冲编码调制(PCM)实现编程实现PCM技术的三个过程:采样、量化与编码。采样:低通连续信号采样,以x=sin(200*t);m=x./(200*t);m=m.*m;为例...
脉冲编码调制(PCM)实现
编程实现PCM技术的三个过程:采样、量化与编码。
采样:低通连续信号采样,以 x=sin(200*t); m=x./(200*t); m=m.*m;为例说明低通采样定理,绘出信号时、频图形;带通连续信号采样,以x=sin(20*t); m=x./t; 为例说明带通采样定理,绘出信号时、频图形。
量化:均匀量化,以幅度 的正弦信号为例实现为64级电平的均匀量化;非均匀量化,输入A律PCM编码器的正弦信号 ,采样序列为 ,将其进行PCM编码,给出编码器的输出码组序列
编码:以上述信号为例,实现A律的13折线近似法及国际标准PCM对数A律量化编码。 展开
编程实现PCM技术的三个过程:采样、量化与编码。
采样:低通连续信号采样,以 x=sin(200*t); m=x./(200*t); m=m.*m;为例说明低通采样定理,绘出信号时、频图形;带通连续信号采样,以x=sin(20*t); m=x./t; 为例说明带通采样定理,绘出信号时、频图形。
量化:均匀量化,以幅度 的正弦信号为例实现为64级电平的均匀量化;非均匀量化,输入A律PCM编码器的正弦信号 ,采样序列为 ,将其进行PCM编码,给出编码器的输出码组序列
编码:以上述信号为例,实现A律的13折线近似法及国际标准PCM对数A律量化编码。 展开
若以下回答无法解决问题,邀请你更新回答
3个回答
展开全部
clear all; close all;
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(200*t); m=x./(200*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=m.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-0.15,0.15,0,1.5]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-500,500,0,0.03]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.005; %满足抽样条件的抽样间隔
fs1=1/ts1;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(200*t1); m1=x1./(200*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=m1.*m1; %定义信号
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-0.15,0.15,0,1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.05]);
title('抽样满足的信号频谱');axis([-500,500,0,0.05]);
t0=10; %信号持续的时间
ts2=0.01; %不满足抽样条件的抽样间隔
fs2=1/ts2;
t2=[-t0/2:ts2:t0/2]; %定义不满足抽样条件的时间序列
x2=sin(200*t2); m2=x2./(200*t2); w2=t0/(2*ts2)+1;
m2(w2)=1; %修正t=0时的信号值
m2=m2.*m2; %定义信号
[M2,mn2,df2]=fft_seq(m2,ts2,df);%对不满足抽样条件的信号进行傅立叶变换
M2=M2/fs2;N2=[M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2];
f2=[-7*df2*length(mn2):df2:6*df2*length(mn2)-df2]-fs2/2;
figure(3)
subplot(2,1,1); stem(t2,m2);
xlabel('时间/s');ylabel('幅值');title('抽样不满足的信号波形');
axis([-0.15,0.15,0,1]);subplot(2,1,2)
plot(f2,abs(fftshift(N2)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.02]);
title('抽样不满足的信号频谱');axis([-500,500,0,0.02]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
2、带通采样信号
clear all; close all;
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(20*t).*cos(100*t); m=x./(20*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=20.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-2,2,-30,30]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-50,50,0,4]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.01;
fs1h=100;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1);
m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1.5,1.5,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,2]);
title('抽样满足的信号频谱');axis([-100,100,0,2]);
t0=10; %信号持续的时间
ts1=0.025;
fs1l=40;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1); m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1l;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1l/2;
figure(3)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1,1,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-50,50,0,2.5]);
title('抽样满足的信号频谱');axis([-50,50,0,2.5]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
3、均匀量化编码
t=[0:0.1:2*pi];
s=sin(t);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,aquan,distor]=quantiz(s,partition,codebook);
figure(1)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,aquan,'*');
codebook
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for i=1:length(s)
for j=nu:-1:0
if(fix(aquan(i)/(2^j))==1)
codebook(i,nu-j)=1;
aquan(i)=aquan(i)-2^j;
end
end
end
codebook
4、非均匀量化编码
1.1例题一
t=[0:0.1:2*pi];
s=sin(t);
dx=0.001;
x=-1:dx:1;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-pi/2,asin(-7/8),asin(-6/8),asin(-5/8),asin(-4/8),asin(-3/8),asin(-2/8),asin(-1/8),asin(1/8),asin(2/8),asin(3/8),asin(4/8),asin(5/8),asin(6/8),asin(7/8),pi/2]
yy=[-1,-7/8,-6/8,-5/8,-4/8,-3/8,-2/8,-1/8,1/8,2/8,3/8,4/8,5/8,6/8,7/8,1]
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,ya,distor]=quantiz(s,partition,codebook);
figure(2)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,ya,'*');axis([0,7,-40,40]);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(ya(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=ya(m)-2^j;
end
end
end
codebook
1.2例题二
t=[0:pi/400:2*pi];
n=[1:1:10];
df=0.5;
s=sin(1600*pi*t);
y=sin(0.2*pi*n);
dx=0.2;
x=-2:dx:2;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10];
yy=[-sin(2*pi),-sin(1.8*pi),-sin(1.6*pi),-sin(1.4*pi),-sin(1.2*pi),-sin(1*pi),-sin(0.8*pi),-sin(0.6*pi),-sin(0.4*pi),-sin(0.2*pi),sin(0.2*pi),sin(0.4*pi),sin(0.6*pi),sin(0.8*pi),sin(1*pi),sin(1.2*pi),sin(1.4*pi),sin(1.6*pi),sin(1.8*pi),sin(2*pi)];
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
t0=1; %信号持续的时间
ts1=1/800;
fs1h=1/ts1;
t1=[0:1/400:2]; %定义满足抽样条件的时间序列
x1=sin(pi*t1);
w1=t0/(2*ts1)+1;
m1=x1;
m1(w1)=1;%修正t=0时的信号值
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,x1);
xlabel('时间/s');ylabel('幅值');
title('抽样信号的波形');axis([0,2,-1.1,1.1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,1]);
title('抽样的信号频谱');axis([-100,100,0,1]);
for j=1:801
for i=1:11
if abs(x1(j))-abs(ya(i))<0
a(j)=ya(i);
else
a(j)=x1(j);
end
i=11;
end
end
figure(3)
plot(t1,a); axis([0,2*pi,-1,2]);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,a,distor]=quantiz(s,partition,codebook);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(a(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=a(m)-2^j;
end
end
end
codebook
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(200*t); m=x./(200*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=m.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-0.15,0.15,0,1.5]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-500,500,0,0.03]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.005; %满足抽样条件的抽样间隔
fs1=1/ts1;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(200*t1); m1=x1./(200*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=m1.*m1; %定义信号
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-0.15,0.15,0,1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.05]);
title('抽样满足的信号频谱');axis([-500,500,0,0.05]);
t0=10; %信号持续的时间
ts2=0.01; %不满足抽样条件的抽样间隔
fs2=1/ts2;
t2=[-t0/2:ts2:t0/2]; %定义不满足抽样条件的时间序列
x2=sin(200*t2); m2=x2./(200*t2); w2=t0/(2*ts2)+1;
m2(w2)=1; %修正t=0时的信号值
m2=m2.*m2; %定义信号
[M2,mn2,df2]=fft_seq(m2,ts2,df);%对不满足抽样条件的信号进行傅立叶变换
M2=M2/fs2;N2=[M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2];
f2=[-7*df2*length(mn2):df2:6*df2*length(mn2)-df2]-fs2/2;
figure(3)
subplot(2,1,1); stem(t2,m2);
xlabel('时间/s');ylabel('幅值');title('抽样不满足的信号波形');
axis([-0.15,0.15,0,1]);subplot(2,1,2)
plot(f2,abs(fftshift(N2)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.02]);
title('抽样不满足的信号频谱');axis([-500,500,0,0.02]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
2、带通采样信号
clear all; close all;
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(20*t).*cos(100*t); m=x./(20*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=20.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-2,2,-30,30]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-50,50,0,4]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.01;
fs1h=100;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1);
m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1.5,1.5,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,2]);
title('抽样满足的信号频谱');axis([-100,100,0,2]);
t0=10; %信号持续的时间
ts1=0.025;
fs1l=40;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1); m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1l;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1l/2;
figure(3)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1,1,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-50,50,0,2.5]);
title('抽样满足的信号频谱');axis([-50,50,0,2.5]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
3、均匀量化编码
t=[0:0.1:2*pi];
s=sin(t);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,aquan,distor]=quantiz(s,partition,codebook);
figure(1)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,aquan,'*');
codebook
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for i=1:length(s)
for j=nu:-1:0
if(fix(aquan(i)/(2^j))==1)
codebook(i,nu-j)=1;
aquan(i)=aquan(i)-2^j;
end
end
end
codebook
4、非均匀量化编码
1.1例题一
t=[0:0.1:2*pi];
s=sin(t);
dx=0.001;
x=-1:dx:1;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-pi/2,asin(-7/8),asin(-6/8),asin(-5/8),asin(-4/8),asin(-3/8),asin(-2/8),asin(-1/8),asin(1/8),asin(2/8),asin(3/8),asin(4/8),asin(5/8),asin(6/8),asin(7/8),pi/2]
yy=[-1,-7/8,-6/8,-5/8,-4/8,-3/8,-2/8,-1/8,1/8,2/8,3/8,4/8,5/8,6/8,7/8,1]
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,ya,distor]=quantiz(s,partition,codebook);
figure(2)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,ya,'*');axis([0,7,-40,40]);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(ya(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=ya(m)-2^j;
end
end
end
codebook
1.2例题二
t=[0:pi/400:2*pi];
n=[1:1:10];
df=0.5;
s=sin(1600*pi*t);
y=sin(0.2*pi*n);
dx=0.2;
x=-2:dx:2;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10];
yy=[-sin(2*pi),-sin(1.8*pi),-sin(1.6*pi),-sin(1.4*pi),-sin(1.2*pi),-sin(1*pi),-sin(0.8*pi),-sin(0.6*pi),-sin(0.4*pi),-sin(0.2*pi),sin(0.2*pi),sin(0.4*pi),sin(0.6*pi),sin(0.8*pi),sin(1*pi),sin(1.2*pi),sin(1.4*pi),sin(1.6*pi),sin(1.8*pi),sin(2*pi)];
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
t0=1; %信号持续的时间
ts1=1/800;
fs1h=1/ts1;
t1=[0:1/400:2]; %定义满足抽样条件的时间序列
x1=sin(pi*t1);
w1=t0/(2*ts1)+1;
m1=x1;
m1(w1)=1;%修正t=0时的信号值
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,x1);
xlabel('时间/s');ylabel('幅值');
title('抽样信号的波形');axis([0,2,-1.1,1.1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,1]);
title('抽样的信号频谱');axis([-100,100,0,1]);
for j=1:801
for i=1:11
if abs(x1(j))-abs(ya(i))<0
a(j)=ya(i);
else
a(j)=x1(j);
end
i=11;
end
end
figure(3)
plot(t1,a); axis([0,2*pi,-1,2]);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,a,distor]=quantiz(s,partition,codebook);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(a(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=a(m)-2^j;
end
end
end
codebook
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
clear all; close all;
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(200*t); m=x./(200*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=m.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-0.15,0.15,0,1.5]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-500,500,0,0.03]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.005; %满足抽样条件的抽样间隔
fs1=1/ts1;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(200*t1); m1=x1./(200*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=m1.*m1; %定义信号
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-0.15,0.15,0,1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.05]);
title('抽样满足的信号频谱');axis([-500,500,0,0.05]);
t0=10; %信号持续的时间
ts2=0.01; %不满足抽样条件的抽样间隔
fs2=1/ts2;
t2=[-t0/2:ts2:t0/2]; %定义不满足抽样条件的时间序列
x2=sin(200*t2); m2=x2./(200*t2); w2=t0/(2*ts2)+1;
m2(w2)=1; %修正t=0时的信号值
m2=m2.*m2; %定义信号
[M2,mn2,df2]=fft_seq(m2,ts2,df);%对不满足抽样条件的信号进行傅立叶变换
M2=M2/fs2;N2=[M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2];
f2=[-7*df2*length(mn2):df2:6*df2*length(mn2)-df2]-fs2/2;
figure(3)
subplot(2,1,1); stem(t2,m2);
xlabel('时间/s');ylabel('幅值');title('抽样不满足的信号波形');
axis([-0.15,0.15,0,1]);subplot(2,1,2)
plot(f2,abs(fftshift(N2)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.02]);
title('抽样不满足的信号频谱');axis([-500,500,0,0.02]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
2、带通采样信号
clear all; close all;
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(20*t).*cos(100*t); m=x./(20*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=20.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-2,2,-30,30]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-50,50,0,4]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.01;
fs1h=100;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1);
m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1.5,1.5,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,2]);
title('抽样满足的信号频谱');axis([-100,100,0,2]);
t0=10; %信号持续的时间
ts1=0.025;
fs1l=40;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1); m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1l;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1l/2;
figure(3)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1,1,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-50,50,0,2.5]);
title('抽样满足的信号频谱');axis([-50,50,0,2.5]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
3、均匀量化编码
t=[0:0.1:2*pi];
s=sin(t);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,aquan,distor]=quantiz(s,partition,codebook);
figure(1)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,aquan,'*');
codebook
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for i=1:length(s)
for j=nu:-1:0
if(fix(aquan(i)/(2^j))==1)
codebook(i,nu-j)=1;
aquan(i)=aquan(i)-2^j;
end
end
end
codebook
4、非均匀量化编码
1.1例题一
t=[0:0.1:2*pi];
s=sin(t);
dx=0.001;
x=-1:dx:1;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-pi/2,asin(-7/8),asin(-6/8),asin(-5/8),asin(-4/8),asin(-3/8),asin(-2/8),asin(-1/8),asin(1/8),asin(2/8),asin(3/8),asin(4/8),asin(5/8),asin(6/8),asin(7/8),pi/2]
yy=[-1,-7/8,-6/8,-5/8,-4/8,-3/8,-2/8,-1/8,1/8,2/8,3/8,4/8,5/8,6/8,7/8,1]
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,ya,distor]=quantiz(s,partition,codebook);
figure(2)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,ya,'*');axis([0,7,-40,40]);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(ya(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=ya(m)-2^j;
end
end
end
codebook
1.2例题二
t=[0:pi/400:2*pi];
n=[1:1:10];
df=0.5;
s=sin(1600*pi*t);
y=sin(0.2*pi*n);
dx=0.2;
x=-2:dx:2;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10];
yy=[-sin(2*pi),-sin(1.8*pi),-sin(1.6*pi),-sin(1.4*pi),-sin(1.2*pi),-sin(1*pi),-sin(0.8*pi),-sin(0.6*pi),-sin(0.4*pi),-sin(0.2*pi),sin(0.2*pi),sin(0.4*pi),sin(0.6*pi),sin(0.8*pi),sin(1*pi),sin(1.2*pi),sin(1.4*pi),sin(1.6*pi),sin(1.8*pi),sin(2*pi)];
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
t0=1; %信号持续的时间
ts1=1/800;
fs1h=1/ts1;
t1=[0:1/400:2]; %定义满足抽样条件的时间序列
x1=sin(pi*t1);
w1=t0/(2*ts1)+1;
m1=x1;
m1(w1)=1;%修正t=0时的信号值
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,x1);
xlabel('时间/s');ylabel('幅值');
title('抽样信号的波形');axis([0,2,-1.1,1.1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,1]);
title('抽样的信号频谱');axis([-100,100,0,1]);
for j=1:801
for i=1:11
if abs(x1(j))-abs(ya(i))<0
a(j)=ya(i);
else
a(j)=x1(j);
end
i=11;
end
end
figure(3)
plot(t1,a); axis([0,2*pi,-1,2]);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,a,distor]=quantiz(s,partition,codebook);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(a(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=a(m)-2^j;
end
end
end
codebook
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(200*t); m=x./(200*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=m.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-0.15,0.15,0,1.5]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-500,500,0,0.03]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.005; %满足抽样条件的抽样间隔
fs1=1/ts1;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(200*t1); m1=x1./(200*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=m1.*m1; %定义信号
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-0.15,0.15,0,1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.05]);
title('抽样满足的信号频谱');axis([-500,500,0,0.05]);
t0=10; %信号持续的时间
ts2=0.01; %不满足抽样条件的抽样间隔
fs2=1/ts2;
t2=[-t0/2:ts2:t0/2]; %定义不满足抽样条件的时间序列
x2=sin(200*t2); m2=x2./(200*t2); w2=t0/(2*ts2)+1;
m2(w2)=1; %修正t=0时的信号值
m2=m2.*m2; %定义信号
[M2,mn2,df2]=fft_seq(m2,ts2,df);%对不满足抽样条件的信号进行傅立叶变换
M2=M2/fs2;N2=[M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2];
f2=[-7*df2*length(mn2):df2:6*df2*length(mn2)-df2]-fs2/2;
figure(3)
subplot(2,1,1); stem(t2,m2);
xlabel('时间/s');ylabel('幅值');title('抽样不满足的信号波形');
axis([-0.15,0.15,0,1]);subplot(2,1,2)
plot(f2,abs(fftshift(N2)));
xlabel('频率/Hz');ylabel('幅值');axis([-500,500,0,0.02]);
title('抽样不满足的信号频谱');axis([-500,500,0,0.02]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
2、带通采样信号
clear all; close all;
t0=10; %定义时间长度
ts=0.001; fs=1/ts;
t=[-t0/2:ts:t0/2]; %定义时间序列
df=0.5; %定义频率分辨率
x=sin(20*t).*cos(100*t); m=x./(20*t);
w=t0/(2*ts)+1; %确定t=0的点
m(w)=1; %修正t=0点的信号值
m=20.*m;
[M,mn,dfy]=fft_seq(m,ts,df); %傅立叶变换
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2; %定义频率序列
figure(1)
subplot(2,1,1); plot(t,m);
xlabel('时间/s');ylabel('幅值');title('原信号的波形');
axis([-2,2,-30,30]);
subplot(2,1,2);
plot(f,abs(fftshift(M)));
xlabel('频率/Hz');ylabel('幅值');
axis([-50,50,0,4]);title('原信号的频谱');
t0=10; %信号持续的时间
ts1=0.01;
fs1h=100;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1);
m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1.5,1.5,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,2]);
title('抽样满足的信号频谱');axis([-100,100,0,2]);
t0=10; %信号持续的时间
ts1=0.025;
fs1l=40;
t1=[-t0/2:ts1:t0/2]; %定义满足抽样条件的时间序列
x1=sin(20*t1).*cos(100*t1); m1=x1./(20*t1); w1=t0/(2*ts1)+1;
m1(w1)=1; %修正t=0时的信号值
m1=20.*m1;
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1l;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1l/2;
figure(3)
subplot(2,1,1); stem(t1,m1);
xlabel('时间/s');ylabel('幅值');
title('抽样满足信号的波形');axis([-1,1,-20,30]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-50,50,0,2.5]);
title('抽样满足的信号频谱');axis([-50,50,0,2.5]);
function [M,m,df]=fft_seq(m,ts,df)
fs=1/ts;
if nargin==2
n1=0
else
n1=fs/df
end
n2=length(m);n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);m=[m,zeros(1,n-n2)];df=fs/n;
3、均匀量化编码
t=[0:0.1:2*pi];
s=sin(t);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,aquan,distor]=quantiz(s,partition,codebook);
figure(1)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,aquan,'*');
codebook
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for i=1:length(s)
for j=nu:-1:0
if(fix(aquan(i)/(2^j))==1)
codebook(i,nu-j)=1;
aquan(i)=aquan(i)-2^j;
end
end
end
codebook
4、非均匀量化编码
1.1例题一
t=[0:0.1:2*pi];
s=sin(t);
dx=0.001;
x=-1:dx:1;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-pi/2,asin(-7/8),asin(-6/8),asin(-5/8),asin(-4/8),asin(-3/8),asin(-2/8),asin(-1/8),asin(1/8),asin(2/8),asin(3/8),asin(4/8),asin(5/8),asin(6/8),asin(7/8),pi/2]
yy=[-1,-7/8,-6/8,-5/8,-4/8,-3/8,-2/8,-1/8,1/8,2/8,3/8,4/8,5/8,6/8,7/8,1]
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,ya,distor]=quantiz(s,partition,codebook);
figure(2)
subplot(2,1,1);
plot(t,s);
subplot(2,1,2);
plot(t,ya,'*');axis([0,7,-40,40]);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(ya(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=ya(m)-2^j;
end
end
end
codebook
1.2例题二
t=[0:pi/400:2*pi];
n=[1:1:10];
df=0.5;
s=sin(1600*pi*t);
y=sin(0.2*pi*n);
dx=0.2;
x=-2:dx:2;
A=87.6;
for i=1:length(x)
if abs(x(i))<1/A
ya(i)=A*x(i)/(1+log(A));
else
ya(i)=sign(x(i))*(1+log(A*abs(x(i))))/(1+log(A));
end
end
figure(1)
plot(x,ya,'k.:');
title('A')
xlabel('x');
ylabel('y');
grid on
hold on
xx=[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10];
yy=[-sin(2*pi),-sin(1.8*pi),-sin(1.6*pi),-sin(1.4*pi),-sin(1.2*pi),-sin(1*pi),-sin(0.8*pi),-sin(0.6*pi),-sin(0.4*pi),-sin(0.2*pi),sin(0.2*pi),sin(0.4*pi),sin(0.6*pi),sin(0.8*pi),sin(1*pi),sin(1.2*pi),sin(1.4*pi),sin(1.6*pi),sin(1.8*pi),sin(2*pi)];
plot(xx,yy,'r');
stem(xx,yy,'b-.');
legend('A律压缩特性','折线近似A律');
t0=1; %信号持续的时间
ts1=1/800;
fs1h=1/ts1;
t1=[0:1/400:2]; %定义满足抽样条件的时间序列
x1=sin(pi*t1);
w1=t0/(2*ts1)+1;
m1=x1;
m1(w1)=1;%修正t=0时的信号值
[M1,mn1,df1]=fft_seq(m1,ts1,df); %对满抽样条件的信号进行傅立叶变换
M1=M1/fs1h;N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1h/2;
figure(2)
subplot(2,1,1); stem(t1,x1);
xlabel('时间/s');ylabel('幅值');
title('抽样信号的波形');axis([0,2,-1.1,1.1]);
subplot(2,1,2)
plot(f1,abs(fftshift(N1)));
xlabel('频率/Hz');ylabel('幅值');axis([-100,100,0,1]);
title('抽样的信号频谱');axis([-100,100,0,1]);
for j=1:801
for i=1:11
if abs(x1(j))-abs(ya(i))<0
a(j)=ya(i);
else
a(j)=x1(j);
end
i=11;
end
end
figure(3)
plot(t1,a); axis([0,2*pi,-1,2]);
partition=[-1:1/32:1];
codebook=[-32:1:32];
[index,a,distor]=quantiz(s,partition,codebook);
nu=ceil(log2(64));
codebook=zeros(length(s),nu)
for m=1:length(s)
for j=nu:-1:0
if(fix(a(m)/(2^j))==1)
codebook(m,nu-j)=1;
ya(m)=a(m)-2^j;
end
end
end
codebook
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你都敢跑着来问,小心我告诉你辅导员。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询