Overload basic arithmetic for classes arrays?

2 visualizaciones (últimos 30 días)
Alex Kashuba
Alex Kashuba el 24 de Mzo. de 2020
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?

Respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by