summaryrefslogtreecommitdiff
path: root/2048/DEPENDENCIES/imc_stable.sci
blob: d53da9c82478f57612c8264a298337176a7ca081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Design of conventional controller which is an equivalent of internal model controller
// 10.9

// Designs Discrete Internal Model Controller
// for transfer function z^{-k}B(z^{-1})/A(z^{-1})
// Numerator and Denominator of IMC HQ are outputs
// Controller is also given in R,S form 


function [k,HiN,HiD,R,S,mu] = imc_stable(B,A,k,alpha)

[Kp,d,Bg,Bnmp,Bm] = imcsplit(B,mtlb_logical(1));
Bg = Kp * Bg;

Bnmpr = flip(Bnmp);
Bms = sum(Bm);
HiN = A;
HiD = Bms * convol(Bg,Bnmpr);
k = k+d;

[zk,dzk] = zpowk(k);
Bf = (1-alpha);
Af = [1 -alpha];
S = convol(Bf,A);
R1 = convol(Af,convol(Bnmpr,Bms));
R2 = convol(zk,convol(Bf,convol(Bnmp,Bm)));

[R,dR] = poladd(R1,length(R1)-1,-R2,length(R2)-1);
R = convol(Bg,R);
endfunction;