calculation mean as index for columns

조회 수: 8 (최근 30일)
expert
expert 2019년 11월 23일
댓글: Image Analyst 2019년 11월 24일
Hi,
I want o calculation mean for 12850x22 matrix. First of all I calculated some values with for loop, after normalized data. But I could not calculate true means for colums.
I m trying this:
%import table from same directory
T = readtable("T.xlsx", "UseExcel", false);
%convert table to matrix except first column
T = T{:,2:23};
cols = size(T,2);
for i = 2:cols
res(:,i-1) = T(:,i)./T(:,1);
res_norm = normalize(res,'norm',Inf);
res_mean = mean(res); %but these are not true means, I need index number but how?
end

답변 (1개)

Image Analyst
Image Analyst 2019년 11월 23일
Why not
meanOfThisColumn = mean(T{:,i}); % Braces for T, not parentheses.
You forgot to attach T.xlsx. I'll check back later.
  댓글 수: 2
expert
expert 2019년 11월 24일
Hi
Thank you for your response. But there is an error with this command:
Brace indexing is not supported for variables of this type.
Error in Untitled4 (line 10)
res_m = mean(res{:,i});
I attached file.
Image Analyst
Image Analyst 2019년 11월 24일
See how important it is to include relevant data in advance?
Try this:
T = readtable('T.xlsx', 'UseExcel', false);
% Convert table to matrix except first column and first row.
numbers = T{2 : end, 2 : end};
columnMeans = mean(numbers, 1)

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by