-
Notifications
You must be signed in to change notification settings - Fork 0
/
hinfmax.m
76 lines (69 loc) · 2.05 KB
/
hinfmax.m
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function [gamma,ind] = hinfmax(sys,freq)
%HINFMAX Maximum of H-inf norms of columns of a transfer function matrix
% [GAMMA,IND] = HINFMAX(SYS) computes GAMMA, the maximum of the H-infinity
% norms of the columns of the transfer function matrix G of the stable LTI
% system SYS. IND is the index of the column for which the maximum is
% achieved.
%
% [GAMMA,IND] = HINFMAX(SYS,FREQ) computes for a real vector of frequency
% values FREQ, GAMMA, the maximum of the 2-norms of the columns of the
% frequency responses of G evaluated for all values contained in FREQ.
% IND is the index of the column for which the maximum is achieved.
%
% Note: The stability of SYS is not checked.
% Copyright 2018 A. Varga
% Author: A. Varga, 11-06-2018.
% Revisions:
narginchk(1,2)
nargoutchk(0,2)
% check input system form
if ~isa(sys,'lti')
error('The input system SYS must be an LTI system object')
end
m = size(sys,2);
if m == 0
gamma = []; ind = [];
return
end
if nargin == 1
freq = [];
else
if ~isempty(freq)
validateattributes(freq, {'double'},{'real','vector','>=',0},'','FREQ',2)
end
end
gamma = 0; ind = 1;
if ~isempty(freq)
% evaluate GAMMA as the maximum of the norms of columns of the frequency
% responses of G evaluated over all frequencies contained in FREQ
if isequal(freq,0)
% use DCGAIN if only frequency 0 is present
frgains = dcgain(sys);
for j = 1:m
temp = norm(frgains(:,j));
if gamma < temp
gamma = temp; ind = j;
end
end
else
for i = 1:length(freq)
frgains = freqresp(sys,freq(i));
for j = 1:m
temp = norm(frgains(:,j));
if gamma < temp
gamma = temp; ind = j;
end
end
end
end
else
% evaluate BETA as the minimum of H-infinity norms of the columns of G
for j = 1:m
temp = norm(sys(:,j),inf);
if gamma < temp
gamma = temp; ind = j;
end
end
end
% end HINFMAX
end