How do I use a for loop to read rows of a matrix?

1 次查看(过去 30 天)
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?

回答(1 个)

John
John 2016-7-1
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)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by