?? test_2_nonlin.m
字號:
clc; clear; clf;
% non-linear transforms
warning off;
%the number of the input-output bits...
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;
% 1. Compression: x input; y output
n = length(x);
for i=1:n,
if x(i) >= 0,
y(i) = out_range * log2(x(i) / in_range + 1) / 2;
else
y(i) = -out_range * log2(x(i) / in_range - 1) / 2;
end;
end;
% 2. Extention: y input ; xb output
for i=1:n,
if y(i) >=0,
xb(i) = in_range * 2^(2*y(i) / out_range) - in_range;
else
xb(i) = - in_range *( -1 / ( 2^(2*y(i) / out_range)) ) + in_range ;
end;
end;
subplot(221), stairs(x,y); title('Compression');
axis([x_min x_max y_min y_max]); grid;
subplot(222), stairs(y,xb); title('Expanding');
grid;
% axis([x_min x_max x_min x_max]);
subplot(223), plot(x, xb);grid;
title('transfer characteristic');
subplot(224), stairs(x, (xb -x) ./ x .* 100);
axis([x_min x_max x_min x_max]);title('Reconstruction Error [%]');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -