📄 test_2.m
字号:
clc; clear; clf;
% nonlinear transforms
%the numbar of the inputs bits...
% only pozitive values ...
nbits_in = 15 ;
nbits_out = 7;
% define the range
x_min = -2^nbits_in ;
x_max = + 2^nbits_in -1;
in_range = x_max - x_min;
step = 100;
x = x_min:step:x_max;
y_min = - 2^nbits_out ;
y_max = + 2^nbits_out -1;
out_range = y_max - y_min;
n=length(x);
for i=1:n,
xx = out_range * log2(x(i) / in_range + 1) / 2;
if x(i) >=0,
y(i) = xx; else y(i) = + xx;
end;
end;
xb = (in_range / out_range) * y;
subplot(221), stairs(x,y); title('Compression');
subplot(222), stairs(y,xb,'r'); title('Expanding')
% transfer characteristic ...
% x = -max(I_all) : 0.01: max(I_all);
% xc = f_bit_compression(x, nbits_in, nbits_out);
subplot(223), stairs(x,xb);
subplot(224),stairs(x, (xb -x) ./ x .* 100);
title('Reconstruction Error [%]');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -