Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
If statement in a for loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi MathWorks
I have a simple loop, where I test in this small sample for 1:4 time periods. If the statement is true, then I would like to print 12 of the returns at a time from RI_vec to retSizeValue1. It is because the if statement is testing an argument based on an annual value, and if it is true I'd like to collect monthly returns for the following year.
The statement is only done for the first 12 observations.
I've tried adjusting line 82, where the task is to be performed, by writing (i(+12),j) but that does not work. This would just result in the statement being performed for observation 13:24.
I've attached the data, the code and a screenshot below.
All the best,
Christoffer
Antworten (1)
Image Analyst
am 24 Dez. 2019
Try to find an algorithm that gives you the starting and stopping indexes, then to print, use
fprintf('%f, ', RI_vec(index1:index2, j));
1 Kommentar
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!