How can I create an array of advanced system objects and perform the step method on individual array elements?
이전 댓글 표시
I want to create an array of an advanced system object. The object is defined as shown in the code below:
classdef array_test2 < matlab.System
properties
% Public, tunable properties.
Value
end
methods
function obj = array_test2(F)
if nargin ~= 0 % Allow nargin == 0 syntax
m = size(F);
obj(m) = array_test2; % Preallocate object array
for i = 1:m
obj(i).Value = F(i);
end
end
end
end
end
function y = stepImpl(obj,u,v)
y = u*v;
end
Now I create an object of array_test2 as follows:
F = [1;2;3;4;5];
Arr_Test = array_test2(F); % Create 5-by-5 array of objects
This results in the following error:
Array formation and parentheses-style indexing with objects of class 'array_test2' is not allowed. Use objects of class 'array_test2' only as scalars or use a cell array.
I noticed that if I delete: < matlab.System, which is placed after classdef array_test2, the error will not appear. When I now try to perform a step on the first object of Arr_Test as follows:
y = step(Arr_Test(1),1,5);
This results in the following error:
Error using tf (line 287) The values of the "num" and "den" properties must be row vectors or cell arrays of row vectors, where each vector is nonempty and containing numeric data. Type "help tf.num" or "help tf.den" for more information.
It appears to me that I should not delete < matlab.System. Is there anyone who knows how I can create an array of avandced system objects and how I can perform the step method on each object in the array separately?
채택된 답변
추가 답변 (1개)
Jan Kappen
2024년 6월 25일
Need to come back to this question. Apparently, matlab.System and matlab.mixin.Heterogneous are not compatible..
classdef RandomDataGeneratorBase < matlab.System & matlab.mixin.CustomDisplay & matlab.mixin.Heterogeneous
methods
function obj = RandomDataGeneratorBase()
end
end
end
Results in Method 'cat' in class 'matlab.mixin.Heterogeneous' conflicts with the sealed method in superclass 'matlab.mixin.internal.Scalar'. Overriding a sealed method is not supported.
Any ideas how to fix that?
카테고리
도움말 센터 및 File Exchange에서 Create System Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!