Add functions to generate weights and CF
This commit is contained in:
parent
3fb03c1d29
commit
ea35194620
1394
matlab/index.org
1394
matlab/index.org
File diff suppressed because it is too large
Load Diff
28
matlab/matlab/src/generateCF.m
Normal file
28
matlab/matlab/src/generateCF.m
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
function [H1, H2] = generateCF(W1, W2, args)
|
||||||
|
% createWeight -
|
||||||
|
%
|
||||||
|
% Syntax: [W] = generateCF(args)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - W1 - Weighting Function for H1
|
||||||
|
% - W2 - Weighting Function for H2
|
||||||
|
% - args -
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - H1 - Generated H1 Filter
|
||||||
|
% - H2 - Generated H2 Filter
|
||||||
|
|
||||||
|
arguments
|
||||||
|
W1
|
||||||
|
W2
|
||||||
|
args.method char {mustBeMember(args.method,{'lmi', 'ric'})} = 'ric'
|
||||||
|
args.display char {mustBeMember(args.display,{'on', 'off'})} = 'on'
|
||||||
|
end
|
||||||
|
|
||||||
|
P = [W1 -W1;
|
||||||
|
0 W2;
|
||||||
|
1 0];
|
||||||
|
|
||||||
|
[H2, ~, gamma, ~] = hinfsyn(P, 1, 1,'TOLGAM', 0.001, 'METHOD', args.method, 'DISPLAY', args.display);
|
||||||
|
|
||||||
|
H1 = 1 - H2;
|
39
matlab/matlab/src/generateWF.m
Normal file
39
matlab/matlab/src/generateWF.m
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
function [W] = generateWF(args)
|
||||||
|
% createWeight -
|
||||||
|
%
|
||||||
|
% Syntax: [W] = generateWeight(args)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - n - Weight Order (integer)
|
||||||
|
% - G0 - Low frequency Gain
|
||||||
|
% - G1 - High frequency Gain
|
||||||
|
% - Gc - Gain of the weight at frequency w0
|
||||||
|
% - w0 - Frequency at which |W(j w0)| = Gc [rad/s]
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - W - Generated Weight
|
||||||
|
|
||||||
|
arguments
|
||||||
|
args.n (1,1) double {mustBeInteger, mustBePositive} = 1
|
||||||
|
args.G0 (1,1) double {mustBeNumeric, mustBePositive} = 0.1
|
||||||
|
args.Ginf (1,1) double {mustBeNumeric, mustBePositive} = 10
|
||||||
|
args.Gc (1,1) double {mustBeNumeric, mustBePositive} = 1
|
||||||
|
args.w0 (1,1) double {mustBeNumeric, mustBePositive} = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
mustBeBetween(args.G0, args.Gc, args.Ginf);
|
||||||
|
|
||||||
|
s = zpk('s');
|
||||||
|
|
||||||
|
W = (((1/args.w0)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.Ginf)^(2/args.n)))*s + ...
|
||||||
|
(args.G0/args.Gc)^(1/args.n))/...
|
||||||
|
((1/args.Ginf)^(1/args.n)*(1/args.w0)*sqrt((1-(args.G0/args.Gc)^(2/args.n))/(1-(args.Gc/args.Ginf)^(2/args.n)))*s + ...
|
||||||
|
(1/args.Gc)^(1/args.n)))^args.n;
|
||||||
|
|
||||||
|
% Custom validation function
|
||||||
|
function mustBeBetween(a,b,c)
|
||||||
|
if ~((a > b && b > c) || (c > b && b > a))
|
||||||
|
eid = 'createWeight:inputError';
|
||||||
|
msg = 'Gc should be between G0 and Ginf.';
|
||||||
|
throwAsCaller(MException(eid,msg))
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user