Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
I have to sum the mat2d_SRIz matrices that are renewed at each for cycle. I have to make the accumulation of these matrices. If I write: Matrix_sum = matrix_sum + mat2d_SRIz I can't do it. Any solution?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
file=dir('20190710*.mat');
for i=1:length (file)
load(file(i).name)
mat2d_SRIz(mat2d_SRIz<0)=0;
mat2d_SRIz(find(isnan(mat2d_SRIz)==1))=0;
matrice_somma=zeros(360,240);
%matrice_somma=matrice_somma+mat2d_SRIz(1);
end
0 commentaires
Réponses (1)
Mahesh Taparia
le 19 Nov 2019
Hi Mario,
As per your code, you have initialized the matrice_somma variable inside the for loop, which is every time assigned to matrix of zeros. At the end of the loop, you might be getting content of last file of mat2d_SRIz variable. So, to overcome this, you can initialize matrice_somma outside the loop as follows:
file=dir('20190710*.mat');
matrice_somma=zeros(360,240);
for i=1:length (file)
load(file(i).name)
mat2d_SRIz(mat2d_SRIz<0)=0;
mat2d_SRIz(find(isnan(mat2d_SRIz)==1))=0;
matrice_somma=matrice_somma+mat2d_SRIz(1); % check with mat2d_SRIz(1), whether is the matrix which you want to add (it depends on your data format).
end
Hope it will help.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!