Matlab won't run code but prints it to command window - no error message, status bar: continue entering statement
显示 更早的评论
Every time I try to run the following code, Matlab only prints it to the command window and does not run it. The status bar displays "continue entering statement".
The array allocation has the values -1; 0 or 1. taa_portfolio_returns is an array of zeros and Stocks and Bonds include returns. All arrays have the same size (1271x1).
I don't understand the issue with this loop, i tried restarting Matlab and restarting my computer, but it still appears.
for m=1:size(allocation,1)
if allocation(m,1)==1
taa_portfolio_returns(m,1)=0.7*Stocks(m,1)+0.3*Bonds(m,1)
elseif allocation(m,1)==-1
taa_portfolio_returns(m,1)=0.3*Stocks(m,1)+0.7*Bonds(m,1)
end
end
Any help is highly appreciated!!
2 个评论
Walter Roberson
2021-3-15
That code is not a problem, but some surrounding code might be a problem.
Note by the way that you do not assign to taa_portfolio_returns(m,1) if allocation is anything other than 1 or -1 . That would not cause it to ask to continue entering statement though.
CharlyZoe24
2021-3-15
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!