What function to use to quantize a variable
조회 수: 6 (최근 30일)
이전 댓글 표시
I think this is a fairly simple problem but not sure what Matlab function to use. I have several variables calculated in normal double precision. They are signed and symetrically bounded between a speficied negative and positive value. I need to "quantize" the variables so that they have a resolution of one part in 64 (6 bit) or one part in 128 (7 bit) resolution between the upper and lower bounds. The output should be a normal double percision variable but "quantized" as described. Not sure what Matlab function(s) or scripts to use.
I do not have any additional tooboxes so need to solve within basic Matlab.
Thanks
댓글 수: 1
답변 (1개)
David Hill
2022년 2월 9일
Something like this.
x=100*rand(1000,1)-50;
h=linspace(-50,50,129);%for 128 resolution
[~,~,bin]=histcounts(x,h);
q=x(bin);
참고 항목
카테고리
Help Center 및 File Exchange에서 Cast and Quantize Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!