Vectorizing fsolve: how to use fsolve on matrices instead of loops with parameters

1 Ansicht (letzte 30 Tage)
Dear All, is it possible to solve with fsolve an equation with 5 parameters using matrices instead of 5 for loops iterating on every combination of these 5 parameters?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Jul. 2016
Bearbeitet: Walter Roberson am 18 Jul. 2016
No, it is not.
You can reduce the number of explicit for loops:
[G{1:5}] = ndgrid(Values1, Values2, Values3, Values4, Values5);
results = arrayfun(@(g1,g2,g3,g4,g5) fsolve(... some appropriate arguments...), G{1}, G{2}, G{3}, G{4}, G{5});

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by