Average of data multiples excel sheets

3 ビュー (過去 30 日間)
Ojo Olusola
Ojo Olusola 2021 年 10 月 5 日
コメント済み: Mathieu NOE 2021 年 11 月 19 日
I have one excel file that contains 40 sheets with two column dataseries in each of the sheets. I need a matlab codes that can average the data for the sheet1 - sheet 10, sheets 11 - sheet 20, sheet 21-sheet30, sheet31-sheet40 separately and write the results in sheet 41, sheet 42, sheet 43 and sheet 44 respetively. Can anyone help. Thanks.
Olusola
  2 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 10 月 6 日
hi
can you share a representative excel file ?
tx
Ojo Olusola
Ojo Olusola 2021 年 10 月 6 日
a = xlsread('mydata2a.xlsx')

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

回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 10 月 7 日
hello
so this is my suggestion
as we have here 10 sheets , my demo works for either groupped 2 or 5 sheets
this is driven by the parameter k , and of course it must be choosen accordingly to the number of input sheets
with k = 5 , 2 new sheets are added with the averaged data of sheets 1 to 5 and 6 to 10
with k = 2 , 5 new sheets are added with the averaged data of sheets 1 to 2 , 3 to 4 ,..., 9 to 10
code :
clc
clearvars
% Importing Data from excel across multiple sheets.
filename = 'mydata2a.xlsx';
[~,sheet_name]=xlsfinfo(filename);
nsheets = numel(sheet_name);
% retrieve raw data
for k=1:nsheets % nsheets
[data,~,~]=xlsread(filename,sheet_name{k});
% mean values per sheet
data_mean_one_sheet(k,:) = mean(data);
end
%% export
% mean of k successive sheets among nsheets (total)
k = 5;
for ck = 1:nsheets/k
ind = (1:k)+(ck-1)*k;
data_mean_k_sheets(ck,:) = mean(data_mean_one_sheet(ind,:));
xlswrite(filename,data_mean_k_sheets(ck,:),nsheets+ck);
end
  13 件のコメント
Ojo Olusola
Ojo Olusola 2021 年 11 月 5 日
Thank you, your answer is accepted.
Mathieu NOE
Mathieu NOE 2021 年 11 月 19 日
hello again
sorry , but it seems you didn't press the "accept" button ...
all the best

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

カテゴリ

Help Center および File ExchangeMATLAB Functions in Microsoft Excel についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by