To obtain the coefficient value matrix TransformationDelayMatrix1 for for a method of a class definition NewtonRateConverter
15 ビュー (過去 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 ?
回答 (1 件)
Walter Roberson
2024 年 11 月 12 日 19:19
Your code does not call computeTransformationDelayMatrix1 anywhere, so TransformationDelayMatrix1 is going to be the default []
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!