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!