%% Discrete-Time Weighting Functions
% Create discrete-time weighting functions by specifying the low-frequency gain, high-frequency gain, magnitude of the gain at some intermediate frequency, and sample time.
% Create a weighting function with a sample time of 0.1 s. Specify a gain of 40 dB at low frequency, rolling off to –20 dB at high frequency. Specify further that the gain is about 10 dB at 0.01 rad/s. Provide all gains in absolute units.

Wl = makeweight(100,[0.01,3.16],0.1,0.1);

%
% Create a weighting function with a gain of –10 dB at low frequency, rising to 40 dB at high frequency. Specify a 0 dB crossover frequency of 2 rad/s and a sample time of 0.1 s. To specify a 0 dB crossover frequency, you can use the crossover frequency as the second input argument instead of the vector [freq,mag].

Wh = makeweight(0.316,2,100,0.1);

%
% Plot the magnitudes of the weighting functions to confirm that they meet the response specifications.

bodemag(Wl,Wh)
grid on

% The high-frequency leveling of Wh is distorted due to the proximity of its crossover frequency to the Nyquist frequency.
%
% Copyright 2015 The MathWorks, Inc.