Replace zeros with a number

I am trying to create an upper bound condition for a portfolio weighting problem to equal 2%. How can I replace the zeros in the following matrix to equal 0.02?
UB = zeros(N,1)
Thanks

回答 (1 件)

madhan ravi
madhan ravi 2019 年 3 月 28 日

0 投票

UB(UB==0) = 0.02;
% why not
UB = 0.02*ones(N,1) % in the first place?

カテゴリ

ヘルプ センター および File ExchangePortfolio Optimization and Asset Allocation についてさらに検索

質問済み:

2019 年 3 月 28 日

回答済み:

2019 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by