Digital Signal Processing Reference
In-Depth Information
fprintf('search for limit cycle\n')
start = 0; period = 0; k = 1;
while k<=N
k = k+1;
for m = k+1:N
if s(:,k) == s(:,m)
start = k; period = m-k;
fprintf('limit cycle detected \n')
fprintf('start : %g period : %g\n',start,period)
k = N + 1;
break
end
end
end
% Graphics
FIG1 = figure('Name','dsplab16_1 : 2nd order block with quantized
arithmetic',...
'NumberTitle','off','Units','normal','Position',[.40 .30 .45 .55]);
subplot(2,1,1), plot(0:N-1,y/LSB,'o',0:N-1,yref/LSB,'x'); grid
xlabel('{\itn} \rightarrow'); ylabel('{\ity}[{\itn}] / LSB
\rightarrow')
if start~=0
% limit cycle detected
n1 = start; n2 = start + period;
subplot(2,1,2)
plot(s(1,n1:n2)/LSB,s(2,n1:n2)/LSB,'ro',s(1,n1:n2)/LSB,s(2,n1:n2)/LSB,
'b')
grid; title(['limit cycle with periode ',num2str(period)]);
xlabel('{\its}_1[{\itn}] / LSB \rightarrow')
ylabel('{\its}_2[{\itn}] / LSB \rightarrow')
else
fprintf('no limit cycle detected\n')
end
Programmbeispiel 18-2 Block 2. Ordnung mit Arithmetik im Zweierkomplement-Format
% 2nd order block for IIR filter with quantization by
% rounding and two's-complement overflow mode
% - signals and filter coefficients in two's-complement format
% [y,s,OC] = filt2_rc(b,a,x,si,w)
% b : numerator coefficients [b0 b1 b2]
% a : denominator coefficients [1 a1 a2]
% x : input sequence
% si : initial values for state space variables [s1 s2]
% w : word length
% y : output sequence
% s : sequences of state space variables
% s(1,:) = s1[n] and s(2,:) = s2[n]
% OC : overflow counter
% filt2_rc.m * mw * 02/01/2006
function [y,s,OC] = filt2_rc(b,a,x,si,w)
LSB = 2^(-w+1);
% least significant bit
% Memory allocations
N = length(x); s = zeros(2,N+1); y = zeros(1,N); OC = 0;
% Two's-complement numbers
s(:,1) = min(si',1-LSB); s(:,1) = max(s(:,1),-1); % initial values
Search WWH ::




Custom Search