Calculating Mean, Median, STD from an excel documents that has 68 sheets and in each sheet there are 20 columns
조회 수: 18 (최근 30일)
이전 댓글 표시
I have a code that reads the excel document. and created a matrix with 68 tables each one represents one of my sheets.
I need to calculate the average from all the rows in coloumn 13:16 in each of these sheets.
%My Code for reading the excel document.
[status,sheets,xlFormat]=xlsfinfo('Majorfaults_300m_10profiles.xlsx')
for k=1:numel(sheets)
data{k}=xlsread('Majorfaults_300m_10profiles.xlsx',sheets{k});
end
...........................................................................................
%%The following is what I have so far to calculate the values but it is not returning right values and only 24 values rather than 68
for k=1:68 %68 tables (sheets from my excel document)
for n = 1:4 % 4 coloums in each sheet where the values need to be calculated
for i = 13:16 %the coloums in the excel sheet the values are calculated from
minimum(n)= min( data{k}(3:end,i));
maximum(n)= max( data{k}(3:end,i));
average(n)= mean( data{k}(3:end,i));
medi(n)= median( data{k}(3:end,i));
end
end
end
댓글 수: 0
채택된 답변
Mathieu NOE
2021년 12월 2일
편집: Mathieu NOE
2021년 12월 2일
hello Sophie
you can do everything within the first for loop
I assumed that the min/max / med / average computation muts give 4 values per sheet as you want these results per column
results are stored as cell arrays - other options are also doable
%My Code for reading the excel document.
[status,sheets,xlFormat]=xlsfinfo('Majorfaults_300m_10profiles.xlsx');
for k=1:numel(sheets)
data=xlsread('Majorfaults_300m_10profiles.xlsx',sheets{k});
data_extract = data(3:end,13:16); %the colums in the excel sheet the values are calculated from
minimum{k}= min(data_extract,[],1);
maximum{k}= max(data_extract,[],1);
average{k}= mean(data_extract,1);
medi{k}= median(data_extract,1);
end
댓글 수: 7
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!