Data Output as matrix using For Loop
Mostra commenti meno recenti
I have been reading data from matrix Pbc1(30001*3). Now what i want is Sum of all the number present in column 2 within a range of 100 and store them as new matrix. As in, i want to get sum of number from 1-100 present in column 2 and then 101-201 and so on and then store then in new matrix T(300*1).
for n=1:300
s=sum (Pbc1{1+(n-1)*100:n*100,2});
end
but Problem i am facing is s which is output is final sum value i.e sum of number in column 2 of rows 29900-30000 instead of showing all the values. So is it possible to get desired out like below
1 20
2 25
3 60
4 32
and so on.
Other method which i tried was
for n=1:30001:100
s=sum (Pbc1{n:n+100,2});
end
both of them resulted in same answer.
I have attached text file of data.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!