Matlab brute force approach

I want to use Matlab to find the best allocations in some optimization problems. I'm trying to write a script to brute force all possible allocations so:
w1 + w2 + w3 = 1
w1 - 0:1, with step 0.01
I'm trying to use loop function, but I can't figure out how it should work.

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 10 月 13 日

1 投票

See ndgrid(). If possible, vectorize your function; if not, consider using arrayfun()
Or, use bsxfun with w1 and w2 as the two arrays (since w3 = 1 - (w1 + w2))

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2013 年 10 月 13 日

回答済み:

2013 年 10 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by