Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to simulate a quantizer in Matlab?

Status
Not open for further replies.

bob_lv

Member level 1
Joined
Dec 19, 2005
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,673
matlab problem

In the figure, if the quantizer output is 16-bit binnary,4 MSBs are out, the left 12 LSBs are feedback. How to simulate the quantizer in matlab? My main problem is I don't know how to deal with binary numbers in matlab.
 

bob_lv

Member level 1
Joined
Dec 19, 2005
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,673
Re: matlab problem

N=2^14;
width=16;
in=1024*ones(1,N);
feedback(1)=0;
sum_b(1)=0;
sum_c(1)=0;
sa(1)=in(1);
for t=2:N;
sum_a(1)=sa(1);
sum_b(t)=sum_a(t-1)+sum_b(t-1);
sum_c(t)=sum_b(t)+sum_c(t-1);
sum(t)=bitshift(sum_a(t-1),1)+sum_b(t)+sum_c(t);
half_sum(t)=bitshift(sum(t),-1);
out(t)=bitshift(sum(t),4-width);
out_value(t)=bitshift(out(t),width-4);
feedback(t)=half_sum(t)-out_value(t);
sa(t)=in(t)-feedback(t);
sum_a(t)=sa(t)+sum_a(t-1);
end
This is my matlab program. 4 MSBs are output, the left 12 LSBs are feedback. The result is: when 'in' is smaller than 1024, after some cycles the feedback turn to be the same with 'in', and out will be 0. When 'in' is equal to or bigger than 1024, the out and feedback will get huge! Doesn't it mean when the feedback is 12 bits, then the input range is 10 bits?
And why when the input is in this range, the output turn to be zero for ever? According to the theory of modulator, the output is not this. I don't know what's the problem.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top