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

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.
Thank you for your quick reply !
I know, I still need to add a third if statement for assigning values if allocation = 0.
I copied my whole code in a new script und ran it again and now it seems to work..

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2021년 3월 15일

댓글:

2021년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by