フィルターのクリア

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

3 ビュー (過去 30 日間)
Noah Acosta
Noah Acosta 2016 年 6 月 29 日
回答済み: John 2016 年 7 月 1 日
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 件のコメント
Noah Acosta
Noah Acosta 2016 年 6 月 29 日
all on the same plot

サインインしてコメントする。

回答 (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 Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by