Count number of smaller than the threshold in the certain rows of cell arrays

Dear all,
I have a 1 x 3 cell array, each 3 array includes 360x1 double. For each 1 to 360 rows stored in every 3 arrays, I want to know how many times I have smaller than -0.5 values. For example, I want to consider all first rows in each array and count that there is any smaller than -0.5 exist in them. Then consider all second rows in each array, and so on. I don't want to look at each array individually but I need to consider every row in all arrays as integrated rows.
So input is 1 x 3 cell array. And the output is: 3 x 1 double (number of times each row has smaller than -0.5 values)
Any advice is really helpful
Thank you.

 채택된 답변

Matt J
Matt J 2020년 12월 17일
편집: Matt J 2020년 12월 17일
sum(cell2mat(CELL)<-0.5,1).'

댓글 수: 3

Thank you, It is really close to what I need, But not exactly what I looking for. I explain my issue below:
For example, if arrays are:
0 -0.9 2 > in the first rows of all arrays it is just one value below -0.5
1.5 -1.5 -2 > in the second rows of all arrays there are two values below -0.5
-0.8 -3 1 > in the third rows of all arrays there are two values below -0.5
I need this output:
1
2
2
Thank you again.
What you described cannot lead to a 3x1 double vector, which is what you said you expected the output to be. However, the modification you're talking about is simply,
sum(cell2mat(CELL)<-0.5,2)
Generally, speaking there doesn't seem to be any reason for you to be holding your data as a cell array. You should just make it into a 360x3 double matrix,
C=cell2mat(CELL);
Thank you so much, Yes you right. This was exactly what I needed.
Best Regards.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

BN
2020년 12월 17일

댓글:

BN
2020년 12월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by