Count smaller than 15 cells in the table coulumns

1 回表示 (過去 30 日間)
BN
BN 2020 年 1 月 16 日
編集済み: Andrei Bobrov 2020 年 1 月 16 日
I have a 125*5 table, I want to know how many cells are smaller than 15 in each column of tmax_m, tmin_m, rrr24, tm_m separately.
something like this:
Capture.JPG
I attached my table (myresults.mat) for you.
Thank you and Best Regards

採用された回答

adeq123
adeq123 2020 年 1 月 16 日
編集済み: adeq123 2020 年 1 月 16 日
The easiest way would be to just scan the table with for/while loop and increment the number of cells when the if condition is match.
tmax_i = 0;
tmin_i = 0;
rrr24_i = 0;
tm_m = 0;
for i = 1:height(results_excel)
if(results_excel.tmax_m(i) < 15)
tmax_i = tmax_i + 1;
end
if(results_excel.tmin_m(i) < 15)
tmin_i = tmin_i + 1;
end
if(results_excel.rrr24(i) < 15)
rrr24_i = rrr24_i + 1;
end
if(results_excel.tm_m(i) < 15)
tm_m = tm_m + 1;
end
end
tmax_i
tmin_i
rrr24_i
tm_m
Output:
tmax_i = 110
tmin_i = 107
rrr24_i = 94
tm_m = 78
  1 件のコメント
BN
BN 2020 年 1 月 16 日
Thank You Very Much

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2020 年 1 月 16 日
編集済み: Andrei Bobrov 2020 年 1 月 16 日
T = varfun(@funir,results_excel,'I',2:5);
T.Properties.VariableNames = results_excel.Properties.VariableNames(2:end);
T.stationNames = {'Number of smaller than 15 cells'};
out = [results_excel;T(:,[end,1:end-1])];
function out = funir(x)
out = sum(x < 15);
end

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by