Alternative for an increasing number of conditions in if-statements
2 次查看(过去 30 天)
显示 更早的评论
Dear all,
My issue:
- I have got a date vector with portfolio rebalancing dates. As the time goes by, the vector length increases as one rebalances. The rebalance frequency is unknown.
- There is also a time table with rankings for each member in the portfolio for a certain period (daily rankings).
For each day I need the rankings from the time table mentioned above in order to compute the daily returns to another matrix (nDates,nAssets). However, the rankings stay unchanged from rebalance date to rebalance date.
I can use a if statement like this:
If ReturnDate>= first rebalance date OR < second rebalance date
do operation which consists of getting the rankings
elseif ReturnDate>= second rebalance Date OR > third rebalance date
do operation which consists of getting other rankings
…
The code continues… However, as the number of rebalance dates increases the elseif statements increases and the code as well. It gets inefficient and by each rebalance date I need to change the code.
Is there any other alternative instead of increasing the number of conditions?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Portfolio Optimization and Asset Allocation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!