How to find out the average of data gathered from a For Loop for a specific column in a table?
1 回表示 (過去 30 日間)
古いコメントを表示
The script is finding out the mean pixel intensities in a ROI as well as other properties of sequential images in the folder.
I am trying to find out how to find the average of a certain column (meanGL) in the table T that is created from data gathered in the For Loop, this part of the code is not working. I am trying to find the average of the meanGL values.
% Creates table from For Loop Values with separate column for each variable
T.Properties.VariableNames={'numberOfPixels1' 'numberOfPixels2 ' 'meanGL'};
%Calculate the average meanGL for those specific layers
B = T(:,[3])
meanVal = mean(B,1)
% Name the file
filename='Thermal Imaging Data.xlsx'
% Write the data into named excel spreadsheet
writetable(T,filename,'Sheet',1,'Range','B2')
The whole script I am using is attatched.
Also if this average could also be displayed in the same excel spreadsheet as the rest of the data that would be wonderful?
4 件のコメント
採用された回答
Peter Perkins
2019 年 2 月 13 日
The problem is that you are passing a table into mean. The table is a container, and what you need to do is to pass the variable in the table to mean. A one-variable table is not the same thing as the one variable.
You have variable names, you should use them!
meanVal = mean(T.meanGL,1);
There's more than one mean going on there, I guess, but I think that does what you are trying to do.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!