To obtain the coefficient value matrix TransformationStateDelayMatrix for for a method of a class definition NewtonRateConverter
26 ビュー (過去 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 Td1 and Td2 are required. Mathematically Td1
M is the Polynomial Order
So I created function file for Td1
function Td1 = compute_Td1(M)
% Create a matrix of binomial coefficients
[I, J] = ndgrid(1:M, 1:M);
binomials = zeros(M, M);
for i = 1:M
binomials(i, 1:i) = arrayfun(@(ii, jj) nchoosek(ii-1, jj-1), I(i, 1:i), J(i, 1:i));
end
% Create a matrix for powers
powers = ((- (M - 1) / 2) .^ (I - J)) .* (J <= I);
% Element-wise multiplication to get Td1
Td1 = binomials .* powers;
end
This I defined as a static method in NewtonRateConverter
>> compute_Td1(3)
ans =
1 0 0
-1 1 0
1 -2 1
>> compute_Td1(5)
ans =
1 0 0 0 0
-2 1 0 0 0
4 -4 1 0 0
-8 12 -6 1 0
16 -32 24 -8 1
I entered this as a function as a property and method in this class definition NewtonRateConverter
properties
TransformationDelayMatrix1
PolynomialOrder
end
methods
function computeTransformationDelayMatrix1(obj)
% Access PolynomialOrder from superclass
M = obj.PolynomialOrder;
% Compute TransformationDelayMatrix1 using compute_Td1
obj.TransformationDelayMatrix1 = compute_Td1(M);
end
end
When I tried to access this object TransformationDelayMatrix1
% Initialization
myNRC = NewtonRateConverter('InputSampleRate', 44100, 'OutputSampleRate', 48000, 'PolynomialOrder', 3);
myNRC.TransformationDelayMatrix1
In the command window it displays :
>> myNRC.TransformationDelayMatrix1
ans =
[]
Why is this an empty array shown please could you clear out this doubt ?Please could you debugg ?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 Matrix Tz are required. Mathematically Tz
M is the Polynomial Order
So I created function file for Tz
function T_z = calculate_Tz(M)
% Initialize the matrix T_z with zeros
T_z = zeros(M, M);
% Fill the matrix T_z using the given formula
for i = 1:M
for j = 1:i % j goes from 1 to i
T_z(i, j) = nchoosek(i-1, j-1) * (-1)^(j+1);
end
end
end
This I defined as a static method in NewtonRateConverter
>> calculate_Tz(3)
ans =
1 0 0
1 -1 0
1 -2 1
I entered this as a function as a property and method in this class definition NewtonRateConverter
properties
TransformationStateDelayMatrix
end
methods
function computeTransformationStateDelayMatrix(obj)
% Access PolynomialOrder from superclass
M = obj.PolynomialOrder;
% Compute TransformationStateDelayMatrix using calculate_Tz
obj.TransformationStateDelayMatrix = calculate_Tz(M);
end
end
When I tried to access this object TransformationDelayMatrix1
% Initialization
myNRC = NewtonRateConverter('InputSampleRate', 44100, 'OutputSampleRate', 48000, 'PolynomialOrder', 3);
myNRC.TransformationDelayMatrix1
In the command window it displays :
>> myNRC.TransformationStateDelayMatrix
ans =
[]
Why is this an empty array shown please could you clear out this doubt ?Please could you debugg or suggest solution for the problem?
1 件のコメント
Walter Roberson
2024 年 11 月 12 日 21:45
What is the difference between this and the previous https://www.mathworks.com/matlabcentral/answers/2165704-to-obtain-the-coefficient-value-matrix-transformationdelaymatrix1-for-for-a-method-of-a-class-def?s_tid=srchtitle ?
回答 (1 件)
Gayathri
2024 年 11 月 18 日 6:42
I understand that you are getting an empty array for "TransformationStateDelayMatrix". This is because the function for calculating the matrix is not invoked yet.
myNRC = NewtonRateConverter('InputSampleRate', 44100, 'OutputSampleRate', 48000, 'PolynomialOrder', 3);
myNRC.computeTransformationDelayMatrix1();
myNRC.TransformationDelayMatrix1
Now, we will be getting a non-empty array for "TransformationStateDelayMatrix1".
Also, there is no need to mention "PolynomialOrder" in the properties section as this is already inherited.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!