%% 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{[B, A]} =} lp2hp (@var{Bp}, @var{Ap}, @var{wa}) %% Transform a lowpass s-plane filter into an s-plane %% highpass filter with a cutoff frequency of wa %% @seealso{lp2lp, lp2bp, lp2bs} %% @end deftypefn %% Author: Tony Richardson %% Created: 2021-04-09 function [B, A] = lp2hp(Bp, Ap, wa) N = length(Ap); M = length(Bp); A = [wa.^(0:(N-1)).*fliplr(Ap)/Ap(N) zeros(1,M-N)]; B = [wa.^(0:(M-1)).*fliplr(Bp)/Ap(N) zeros(1,N-M)]; 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] = lp2hp(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