Home > utility > scalarQuantize.m

scalarQuantize

PURPOSE ^

scalarQuantize: Scalar quantization

SYNOPSIS ^

function [output, index]=scalarQuantize(input, level)

DESCRIPTION ^

scalarQuantize: Scalar quantization
    Usage:[output, index]=scalarQuantiz(input, level)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [output, index]=scalarQuantize(input, level)
0002 %scalarQuantize: Scalar quantization
0003 %    Usage:[output, index]=scalarQuantiz(input, level)
0004 
0005 %    Roger Jang, 20050121
0006 
0007 if nargin<1; selfdemo; return; end
0008 
0009 boundary=(level(1:end-1)+level(2:end))/2;
0010 index=quantiz(input, boundary)+1;
0011 output=level(index);
0012 
0013 % ====== Selfdemo
0014 function selfdemo
0015 input=10*rand(1, 8);
0016 level=[2 4 8];
0017 [output, index]=feval(mfilename, input, level);
0018 fprintf('input = %s\n', mat2str(input));
0019 fprintf('level = %s\n', mat2str(level));
0020 fprintf('output = %s(input, level) = %s\n', mfilename, mat2str(output));

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003