Calculating Mean, Median, STD from an excel documents that has 68 sheets and in each sheet there are 20 columns
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sophie Freunek
am 2 Dez. 2021
Kommentiert: Mathieu NOE
am 3 Dez. 2021
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 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 2 Dez. 2021
Bearbeitet: Mathieu NOE
am 2 Dez. 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!