%% 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]} =} lp3lp (@var{b}, @var{a}, @var{Wo})
%% @deftypefnx {}{@var{[At,Bt,Ct,Dt]} =} lp3lp (@var{A}, @var{B}, @var{C}, @var{D}, @var{Wo})
%%
%% [bt, at] = lp3lp(b, a, Wo) transforms an analog lowpass filter in transfer
%% function form to an analog lowpass filter with a different cutoff frequency (Wo).
%%
%% [At,Bt,Ct,Dt] = lp3lp(A, B, C, D, Wo) transforms an analog lowpass filter in state
%% space form to an analog lowpass filter with a different cutoff frequency (Wo).
%% @seealso{lp2hp, lp2bp, lp2bs}
%% @end deftypefn
%% Author: Tony Richardson
%% Created: 2021-04-09
function [BT AT XO1 XO2] = lp3lp(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, false);
if (nargout == 4)
[BT AT XO1 XO2] = tf2ss(BT, AT);
end
end
%!demo
%! [z p k] = cheb1ap(8, 3);
%! [b a] = zp2tf(z, p, real(k));
%!
%! Wo = 2*pi*30;
%! [bt at] = lp3lp(b, a, Wo);
%!
%! w = logspace(-2, 1, 501);
%! H = freqs(b, a, w);
%! figure(1)
%! clf
%! subplot(2, 1, 1)
%! loglog(w, abs(H))
%! grid on
%! subplot(2, 1, 2)
%! semilogx(w, rad2deg(angle(H)))
%! grid on
%!
%! w = logspace(0, 3, 501);
%! H = freqs(bt, at, w);
%!
%! figure(2)
%! clf
%! subplot(2, 1, 1)
%! loglog(w, abs(H))
%! grid on
%! subplot(2, 1, 2)
%! semilogx(w, rad2deg(angle(H)))
%! grid on