Function handle for combinations of calculations
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I am trying to create (a) function handle(s) that support every possible combination of addition and subtraction among the specified variables.
Assume we have @(a, b, x, y, z), an exemplary subset of all possible combinations would be:
a - (b + x + y + z)
z - (a + b + x + y)
x - (a + b + y + z)
(x + a + z) - (b + y)
(z + a + b + y) - x
(a + b) - (x + y + z)
... (and many more)
As you can tell the combinations should solely support addition and subtraction, with any possible number of elements on either side of the equation.
Can anyone guide me through the function calls that would support this? I have thought of using either perms or combnk and use 1s and -1s so as to apply "weights" and use a simple addition instead, with the sign of each weight dictating the addition/subtraction, but I am not entirely sure how to process this.
Any help will be appreciated
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!