필터 지우기
필터 지우기

How to calculate the mean from cell when each cell is a different double.

조회 수: 1 (최근 30일)
Hi Im reading excel files and storing them into data{k} so my data is 1x34 cell and each cell is a double, with variable column number and fixed row 13, now i want to calculate mean of 34 files for column and row 1 and do the same for the rest.I tried cell2mat but this doesnt work as i have different values for columns.
folder='E:\Engine image\E100 cycles\All Excel Files';
filetype='*.xlsx';
f=fullfile(folder,filetype);
d=dir(f);
for k=1:numel(d);
data{k}=xlsread(fullfile(folder,d(k).name));
end

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 8월 22일
편집: Andrei Bobrov 2016년 8월 22일
EDIT
m = numel(data);
[ii,~]= cellfun(@size,data);
a = nan(max(ii),size(data{1},2),m);
for jj = 1:m
a(1:ii(jj),:,jj) = data{jj};
end
out = nanmean(a,3);
  댓글 수: 1
mohsen moslemin
mohsen moslemin 2016년 8월 22일
i think this makes it easier to explain i have 34 excel like this what i want is to read them all, what ive done so far now i want to average each value from 34 data, eventually i should have same matrix but each value is the average of 34 values.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 22일
cellfun(@(x) mean(x,2),data,'un',0)
  댓글 수: 5
Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 22일
편집: Azzi Abdelmalek 2016년 8월 22일
This is not clear, to make your problem clear, you can post a short example, and also post the expected result, you haven't specified clearly what mean we have to calculate. You said also, that your matrices are not the same sizes
mohsen moslemin
mohsen moslemin 2016년 8월 22일
Azzi abdelmalek, thanks for your comments sorry this is actually m first time in here so i apologize if something wasn't clear enough.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by