To obtain the coefficient value matrix Transforma​tionDelayM​atrix1 for for a method of a class definition NewtonRateConverter

15 vues (au cours des 30 derniers jours)
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 ?

Réponses (1)

Walter Roberson
Walter Roberson le 12 Nov 2024 à 19:19
Your code does not call computeTransformationDelayMatrix1 anywhere, so TransformationDelayMatrix1 is going to be the default []

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by