How to find the percentage of smaller than X in a specific column in all tables in a cell
2 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone
I have a cell with four "360x5 tables" inside it. I want to understand the percentages of smaller than 0.5 in the all fifth columns of all tables (together) across this cell.
What I need as output is just one 360x1.
for example,
I attached my cell.
Thank you
0 件のコメント
採用された回答
Subhadeep Koley
2020 年 11 月 12 日
clc
load CELL.mat
% Extract all 5th columns
newMat = zeros(360, 1);
for idx = 1:length(CELL)
newMat(:, idx) = CELL{1}.col5;
end
% Calculate percentage of smaller than 0.5
result = zeros(360, 1);
for idx = 1:length(newMat)
smallerThn = nnz(newMat(idx, :) < 0.5);
result(idx, 1) = (smallerThn / numel(newMat(idx, :))) * 100;
end
% Convert the result into Table
T = array2table([newMat, result],...
'VariableNames', {'5th column of first table',...
'5th column of second table',...
'5th column of third table',...
'5th column of fourth table',...
'Percentage of smaller than 0.5'});
disp(T)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!