Combining several loops in one big loop
Afficher commentaires plus anciens
Hello everyone,
i need help with the creation of a loop. I have to create a variable which can be described as follows. For each fiscal year, consisting of 12 months from July of one year to July of the next year, i have to put in the same value. Then i have to move one year forward and repeat it, and so on. The matrix should be created from July 1965 till December 2014 (606x16505 double matrix). I have data available for July 1963 to December 2014 (618x16505 double matrix).
For a better understanding of my problem, i have posted the first 5 loops. As you can see this is not an elegant way to deal with this.
% January 1965-June-1965
for t=1:6
NI(t,:) = (log(sasho(13,:)) - log(sasho(1,:)));
end
% July 1965-June 1966 (this is one fiscal year)
for t=7:18
NI(t,:) = (log(sasho(25,:)) - log(sasho(13,:)));
end
% July 1966-June 1967
for t=19:30
NI(t,:) = (log(sasho(37,:)) - log(sasho(25,:)));
end
% July 1967-June 1968
for t=31:42
NI(t,:) = (log(sasho(49,:)) - log(sasho(37,:)));
end
% July 1968-June 1969
for t=43:54
NI(t,:) = (log(sasho(61,:)) - log(sasho(49,:)));
end
...
% July 2014-December 2014
for t=595:600
NI(t,:) = (log(sasho(613,:)) - log(sasho(601,:)));
end
I hope you got my problem and are able to get a better way coding this than I had.
Thanks in advance.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!