Is possible configure matlab to get a+[ ]=a?

1 Ansicht (letzte 30 Tage)
Dario Mateo Arango Angarita
Kommentiert: Rik am 5 Dez. 2019
ask question
Greetings people.
I currently sent some codes for a software that I developed, and I did not take into account that some values ​​could be empty []. I get some empty values and i had to make a sum, but a + [] = []. It was a big mistake.
Is it possible to configure any option to get a + [] = a without using isEmpty or a command?
Thank you in advance.

Antworten (2)

Matt J
Matt J am 4 Dez. 2019
  2 Kommentare
Rik
Rik am 5 Dez. 2019
Comment posted as answer by Dario Mateo Arango Angarita:
Thank you Matt.
Do you know if is possible edit the double class or plus function in MatLab?
Rik
Rik am 5 Dez. 2019
You should be really careful with editing base components of internal Matlab functions, see this comment for an example why.
Did you try following the advice in the linked pages?
I would strongly suggest using the sum method instead.

Melden Sie sich an, um zu kommentieren.


Matt J
Matt J am 4 Dez. 2019
Bearbeitet: Matt J am 4 Dez. 2019
You could also replace your plus() operations with sum() operations. Compare:
>> a=3; b=[];
>> a+b
ans =
[]
>> sum([a,b])
ans =
3

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by