# How to find the percentage of smaller than X in a specific column in all tables in a cell

조회 수: 1 (최근 30일)
BN 2020년 11월 12일
댓글: BN 2020년 11월 12일
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

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

### 채택된 답변

Subhadeep Koley 2020년 11월 12일
clc
% 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)
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
BN 2020년 11월 12일
Thank you so much

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

### 카테고리

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

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by