To obtain the coefficient value matrix Transforma​​tionDelay​M​atrix2 for for a method of a class definition NewtonRateConverter

25 views (last 30 days)
I have tried to defined a class definition
classdef (StrictDefaults)NewtonRateConverter< dsp.FarrowRateConverter &...
dsp.internal.SupportScalarVarSize & ...
dsp.internal.MultirateEngine &...
dsp.internal.FilterAnalysisMultirate
%Constructor
methods
function obj = NewtonRateConverter(varargin)
% Constructor for the NewtonRateConverter class
setProperties(obj, nargin, varargin{:}, ...
'InputSampleRate', ...
'OutputSampleRate', ...
'OutputRateTolerance', ...
'PolynomialOrder');
end
end
basically it overrides the Farrow Rate Converter and introduce certain conversions over it .
Now for it two Transformation Delay Matrices Td2 are required.Mathematically Td2
M is the Polynomial Order
So I created function file for Td2
function Td2 = compute_Td2(M)
% Initialize Td2 with identity
Td2 = eye(M+1);
for n = 2:M+1
for k = 2:n-1
Td2(n, k) = Td2(n-1, k-1) - (n-2) * Td2(n-1, k);
end
end
Td2 = Td2(2:M+1, 2:M+1);
end
This I defined this as a static method in NewtonRateConverter
>> compute_Td2(3)
ans =
1 0 0
-1 1 0
2 -3 1
>> compute_Td2(5)
ans =
1 0 0 0 0
-1 1 0 0 0
2 -3 1 0 0
-6 11 -6 1 0
24 -50 35 -10 1
I entered this as a function as a property and method in this class definition NewtonRateConverter
properties
TransformationDelayMatrix2
end
methods
function computeTransformationDelayMatrix2(obj)
% Access PolynomialOrder from superclass
M = obj.PolynomialOrder;
% Compute TransformationDelayMatrix2 using compute_Td2
obj.TransformationDelayMatrix2 = compute_Td2(M);
end
end
When I tried to access this object TransformationDelayMatrix2
% Initialization
myNRC = NewtonRateConverter('InputSampleRate', 44100, 'OutputSampleRate', 48000, 'PolynomialOrder', 3);
myNRC.TransformationDelayMatrix2
In the command window it displays :
>> myNRC.TransformationDelayMatrix2
ans =
[]
Why is this an empty array shown please could you clear out this doubt ?Please could you debugg ?

Answers (1)

Naga
Naga on 19 Nov 2024 at 3:48
The issue arises because the 'TransformationDelayMatrix2' property isn't automatically calculated when you create a 'NewtonRateConverter' instance. To fix this, explicitly call the 'computeTransformationDelayMatrix2' method.
For automatic computation during object creation, modify the class constructor to call 'computeTransformationDelayMatrix2' after setting the 'PolynomialOrder' property. Ensure 'PolynomialOrder' is initialized before the method call. Implement these changes to streamline the initialization process.
% Constructor
function obj = NewtonRateConverter(varargin)
% Constructor for the NewtonRateConverter class
setProperties(obj, nargin, varargin{:}, ...
'InputSampleRate', ...
'OutputSampleRate', ...
'OutputRateTolerance', ...
'PolynomialOrder');
% Compute TransformationDelayMatrix2
computeTransformationDelayMatrix2(obj);
end

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!