Create new array for each iteration ?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ok so I have a nested for loop that goes like this:
for i=1:size(L,2) ----L is vector(1:1:7)
filename = ['file_',num2str(L(i))]
filename1 = 'Total result';
Array1 =[]
for j=1:size(M,1)-----M is a vector (3:1:9)
C= do some calculation
Array1 = [Array1;C]
csvwrite(filename,Array1)
end
end
I want to be able to take the values of the array1 for the first iteration and second iteration and add them to get sum of total value. Take the total values and feed it in a new array. I can't seem to get my head around that. Also I want to be able to write the values of Array 1 in each iteration of i and the total values into one csv file. Right now my first and second iteration write to different file purposely. Can you help me and point me in the right direction,please? The most important thing is to actually get the array1 at first iteration then the second array1 at 2nd iteration and add them up once the loop is done. I want the results to be written in the file like this after all the calculation has been done.
Outer loop 1 - Outer loop 2 - Total
Inner loop 1 - Inner loop 2 - inner Loop1 + inner loop 2
Inner loop 1 - inner loop 2
Inner loop 1 - inner loop 2
Inner loop 1 - inner loop 2
3 commentaires
Stephen23
le 18 Avr 2017
@Mini Me: it is not clear what you are trying to achieve. Whatever you do, do NOT try to access lots of arrays in a loop:
Réponses (0)
Voir également
Catégories
En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!