%% Filter Stability
% Design a sixth-order Butterworth highpass IIR filter using second order sections. Specify a normalized 3-dB frequency of 0.7. Determine if the filter is stable.

[z,p,k] = butter(6,0.7,'high');
SOS = zp2sos(z,p,k);    
flag = isstable(SOS)        
zplane(z,p)

%
% Redesign the filter using designfilt and check it for stability.

d = designfilt('highpassiir','DesignMethod','butter','FilterOrder',6, ...
               'HalfPowerFrequency',0.7);
dflg = isstable(d)
zplane(d)

%
% Create a filter and determine its stability at double and single precision.

b = [1 -0.5];
a = [1 -0.999999999];
act_flag1 = isstable(b,a)
act_flag2 = isstable(single(b),single(a))

% Copyright 2015 The MathWorks, Inc.