function [p] = plotMagUncertainty(W, freqs, args) % plotMagUncertainty - % % Syntax: [p] = plotMagUncertainty(W, freqs, args) % % Inputs: % - W - Multiplicative Uncertainty Weight % - freqs - Frequency Vector [Hz] % - args - Optional Arguments: % - G % - color_i % - opacity % % Outputs: % - p - Plot Handle arguments W freqs double {mustBeNumeric, mustBeNonnegative} args.G = tf(1) args.color_i (1,1) double {mustBeInteger, mustBePositive} = 1 args.opacity (1,1) double {mustBeNumeric, mustBeNonnegative} = 0.3 args.DisplayName char = '' end % Get defaults colors colors = get(groot, 'defaultAxesColorOrder'); p = patch([freqs flip(freqs)], ... [abs(squeeze(freqresp(args.G, freqs, 'Hz'))).*(1 + abs(squeeze(freqresp(W, freqs, 'Hz')))); ... flip(abs(squeeze(freqresp(args.G, freqs, 'Hz'))).*max(1 - abs(squeeze(freqresp(W, freqs, 'Hz'))), 1e-6))], 'w', ... 'DisplayName', args.DisplayName); p.FaceColor = colors(args.color_i, :); p.EdgeColor = 'none'; p.FaceAlpha = args.opacity; end