From 2adbead795801a4698bc47d4575b89e49f6082ca Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Thu, 2 May 2024 16:47:50 -0600 Subject: [PATCH] Remove use of BiquadFilter dsp.BiquadFilter will be removed in R2024b. This change switches code to use dsp.SOSFilter on newer MATLAB releases. Signed-off-by: Travis F. Collins --- internal_design_filter.m | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/internal_design_filter.m b/internal_design_filter.m index 0c66b46..2ce6c15 100644 --- a/internal_design_filter.m +++ b/internal_design_filter.m @@ -83,10 +83,23 @@ % Digital representation of the analog filters (It is an approximation for group delay calculation only) [z1,p1,k1] = butter(3,coerce_cutoff(input.wnom/(input.converter_rate/2)),'low'); [sos1,g1] = zp2sos(z1,p1,k1); - Hd1=dsp.BiquadFilter('SOSMatrix',sos1,'ScaleValues',g1); + % Convert Release to number ex: 2014a -> 2014.1, 2014b -> 2014.2 + rel = version('-release'); + relNum = str2double(rel(1:end-1)) + (rel(end) - 'a' + 1) * 0.1; + if relNum >= 2024.1 + [num,den] = sos2ctf(sos1); + Hd1 = dsp.SOSFilter(num,den,ScaleValues=g1,Structure="Direct form I"); + else + Hd1=dsp.BiquadFilter('SOSMatrix',sos1,'ScaleValues',g1); + end [z2,p2,k2] = butter(1,coerce_cutoff(wTIA/(input.converter_rate/2)),'low'); [sos2,g2] = zp2sos(z2,p2,k2); - Hd2=dsp.BiquadFilter('SOSMatrix',sos2,'ScaleValues',g2); + if relNum >= 2024.2 + [num,den] = sos2ctf(sos2); + Hd2 = dsp.SOSFilter(num,den,ScaleValues=g2,Structure="Direct form I"); + else + Hd2=dsp.BiquadFilter('SOSMatrix',sos2,'ScaleValues',g2); + end Hanalog = cascade(Hd2,Hd1); % Define the Pluto DEC8 filter @@ -113,10 +126,20 @@ % Digital representation of the analog filters (It is an approximation for group delay calculation only) [z1,p1,k1] = butter(3,coerce_cutoff(input.wnom/(input.converter_rate/2)),'low'); [sos1,g1] = zp2sos(z1,p1,k1); - Hd1=dsp.BiquadFilter('SOSMatrix',sos1,'ScaleValues',g1); + if relNum >= 2024.2 + [num,den] = sos2ctf(sos1); + Hd1 = dsp.SOSFilter(num,den,ScaleValues=g1,Structure="Direct form I"); + else + Hd1=dsp.BiquadFilter('SOSMatrix',sos1,'ScaleValues',g1); + end [z2,p2,k2] = butter(1,coerce_cutoff(wreal/(input.converter_rate/2)),'low'); [sos2,g2] = zp2sos(z2,p2,k2); - Hd2=dsp.BiquadFilter('SOSMatrix',sos2,'ScaleValues',g2); + if relNum >= 2024.2 + [num,den] = sos2ctf(sos2); + Hd2 = dsp.SOSFilter(num,den,ScaleValues=g2,Structure="Direct form I"); + else + Hd2=dsp.BiquadFilter('SOSMatrix',sos2,'ScaleValues',g2); + end Hanalog = cascade(Hd1,Hd2); % Define the Pluto INT8 filter