How do I use a for loop to read rows of a matrix?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have 5 excel files with different data, each having a matrix with 2 columns and 3204 rows. The first column is the same for each of the files, but the second column is different. I would like to create a for loop (or any loop that is efficient) to first read 1:801 rows and plot the average, then go through the loop again and average and plot 802:1602, then plot the average a third time of 1603:2403. Any advice?
Réponses (1)
John
le 1 Juil 2016
block_size = 801;
vals = zeros(3,1);
for n = 1:5
data = xlsread(['file', num2str(n), '.xlsx']);
for m = 1:3
vals(m) = mean(data(((m-1)*block_size + 1):m*block_size, 2));
end
end
plot(vals)
0 commentaires
Voir également
Catégories
En savoir plus sur Geographic Plots 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!