how to find out the cell array size in for loop with conditions?

1 回表示 (過去 30 日間)
mukesh meharda
mukesh meharda 2020 年 8 月 12 日
コメント済み: KSSV 2020 年 8 月 13 日
I had a cell array size 60*48 and each cell having one value( 1 or less than ), then In a for loop of 1:48 , I want to know in each step the length of cell array or nukber of rows when cell array values is equal to 1.
  2 件のコメント
Arthur Roué
Arthur Roué 2020 年 8 月 12 日
I'm not sure to understand. Can you share some code ? Do you want to know the size of each element in your cell array rows ? What is equal to 1 ?
mukesh meharda
mukesh meharda 2020 年 8 月 13 日
In .mat file, In given cell, I want to know the numbers(count) of 1 in each column which is I am using in for loop for some calculations.
lets say for i=1:48
count(1)=40, % numbers of 1 in column 1st
count(2)=31, % numbers of 1 in column 2nd
and so on.................

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

採用された回答

KSSV
KSSV 2020 年 8 月 13 日
Your mat file has a cell SoC2W. This is of size 60*48. Each element is a cell. You can convert it to matrix using:
M = cell2mat(SoC2W) ;
You matrix will be of size 60*48. So each column has 60 elements.
  2 件のコメント
mukesh meharda
mukesh meharda 2020 年 8 月 13 日
after that how can i count the nymbers where matrix value is 1 in each coulmn
KSSV
KSSV 2020 年 8 月 13 日
idx = M==1 ;
count = sum(idx) ;

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by