%% Copyright (C) 2021 Tony Richardson
%%
%% This program is free software: you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation, either version 3 of the License, or
%% (at your option) any later version.
%%
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%% GNU General Public License for more details.
%%
%% You should have received a copy of the GNU General Public License
%% along with this program. If not, see .
%% -*- texinfo -*-
%% @deftypefn {} {@var{[bt, at]} =} lp3hp (@var{b}, @var{a}, @var{Wo})
%% @deftypefnx {}{@var{[At,Bt,Ct,Dt]} =} lp3hp (@var{A}, @var{B}, @var{C}, @var{D}, @var{Wo})
%%
%% [bt, at] = lp3hp(b, a, Wo) transforms an analog lowpass filter in transfer
%% function form to an analog highpass filter with a different cutoff frequency (Wo).
%%
%% [At,Bt,Ct,Dt] = lp3hp(A, B, C, D, Wo) transforms an analog lowpass filter in state
%% space form to an analog highpass filter with a different cutoff frequency (Wo).
%% @seealso{lp2lp, lp2bp, lp2bs}
%% @end deftypefn
%% Author: Tony Richardson
%% Created: 2021-04-09
function [BT AT XO1 XO2] = lp3hp(BP, AP, Wo, XI1, XI2)
if (nargin == 5)
Wo = XI2;
[BP AP] = ss2tf(BP, AP, Wo, XI1);
elseif nargin!=3
print_usage;
end
[BT AT] = tftrans(BP, AP, Wo, true);
if (nargout == 4)
[BT AT XO1 XO2] = tf2ss(BT, AT);
end
end
%!demo
%! f = 100;
%! [ze pe ke] = ellipap(5, 3, 30);
%! [be ae] = zp2tf(ze, pe, ke);
%!
%! w = logspace(-2, 1, 501);
%! H = freqs(be, ae, w);
%! figure(1)
%! clf
%! semilogx(w, 20*log10(abs(H)))
%! grid
%!
%! [bh ah] = lp3hp(be, ae, 2*pi*f);
%!
%! f = logspace(1, 3, 501);
%! H = freqs(bh, ah, 2*pi*f);
%! figure(2)
%! clf
%! semilogx(f, 20*log10(abs(H)))
%! grid