To obtain the coefficient value matrix TransformationDelayMatrix2 for for a method of a class definition NewtonRateConverter
20 次查看(过去 30 天)
显示 更早的评论
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 ?
0 个评论
回答(1 个)
Naga
2024-11-19,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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!