Overload basic arithmetic for classes arrays?

1 次查看(过去 30 天)
I have a an object obj with several fields, say
obj.a = [1 -1];
obj.b = [0 1; 0 0];
and can override a plus operator
obj = obj1 + obj2
as
obj.a = obj1.a + obj2.a
obj.b = obj1.b + obj2.b
The QUESTION 1: What if I have a class arrays, say obj1(1,2) and obj1(2,1) and want to sum them in the same way as it is performed for double i.e. getting obj(2,2)? Of course I need it for the arbitrary sizes and dimensions. Function arrayfun() is no help, since it does not do implicit expansion. The bsxfun() would do the job, but it is defined for double, int, char, etc.
The QUESTION 2: Same question for mtimes: how can i do matrix multiplication if times function is defined?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by