Calculate average of some specific cell of excel file and print in another excel file

30 visualizaciones (últimos 30 días)
Hi, I have a big excel file with 6 column and 3000 row. For row 4, i have to calculate the average of each five cells like D1:D5, D6:D10 and so on and print it in another excel sheet. Can anyone help me to do that? I can read the file in MATLAB. Thank you.

Respuestas (4)

Image Analyst
Image Analyst el 12 de Ag. de 2016
6 by 3000 is not big - far, far from it.
Try this:
% Read in the data
data = xlsread(inputFilename);
% Extract column D
colD = data(:, 4);
% Reshape to give 5 columns
colD2 = reshape(colD, [], 5);
% Get means going across the columns
theMeans = mean(colD2, 2);
% Write out to a new workbook
xlswrite(outputFilename, theMeans, 'Means', 'A1');

my8950
my8950 el 22 de En. de 2019
I am searching through trying to find some examples to begin working from. I have 0 experience, but the question asked here is similar to what I am after.
Many excel files, I can put them all in one folder location. I want to grab a group of cells in a certain column and average them, then write them to another excel file only containing the results of the average. (O6600:O9293)
There are many columns and cells that I want to do this with, but I think if I can get the first one mentioned above to work, then I can build onto that.
This is a very basic question I think, but when I sitting here looking at a blank screen with no knowledge, its a bit more challenging. I'm open to examples and other suggestions on how to learn as well.
Thank you!

Lei Shen
Lei Shen el 1 de Jul. de 2019
  1. load the excel using function: readtable
  2. extract specific column:
  3. convert table to arry: table2array
  4. reshape the column
  5. calculate the mean of each column using: mean

pranati pradhan
pranati pradhan el 17 de Nov. de 2019
I have same problem,but the specific column for which i want to calculate the average contains some non numeric values(which is showing as NaN(Not a number).I implemented the above code but the average is showing as NaN.Please help me with this.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by