Sign in

username or email:

password:



Not a member?
Forgot your password?

Search code



Search tips

Ads

See Also

Embedded SystemsFPGA

DSP Code Sharing > Uniform Quantization - PCM

Uniform Quantization - PCM

Language: Scilab

Processor: Not Relevant

Submitted by Senthilkumar R on Mar 24 2011

Licensed under a Creative Commons Attribution 3.0 Unported License

Uniform Quantization - PCM


 

This program is used to perform uniform Quantization in pulse code modulation transmission.

 
function [SQNR,xq,en_code] = uniform_pcm(x,L)
  //x = input sequence
  //L = number of qunatization levels
 xmax = max(abs(x));
xq = x/xmax;
en_code = xq;
d = 2/L;
q = d*[0:L-1];
q = q-((L-1)/2)*d;
for i = 1:L
    xq(find(((q(i)-d/2)<= xq)&(xq<=(q(i)+d/2))))=...    
    q(i).*ones(1,length(find(((q(i)-d/2)<=xq)&(xq<=(q(i)+d/2)))));
    en_code(find(xq == q(i)))= (i-1).*ones(1,length(find(xq == q(i))));
end
  xq = xq*xmax;
  SQNR = 20*log10(norm(x)/norm(x-xq));
endfunction
 
Rate this code snippet:
0
Rating: 0 | Votes: 0
 
   
 
posted by Senthilkumar R



Comments


No comments yet for this code


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )