How to get row index satisfy the condition in cell array

17 ビュー (過去 30 日間)
Mekala balaji
Mekala balaji 2019 年 6 月 29 日
コメント済み: madhan ravi 2019 年 6 月 29 日
Hi,
I have celle array, and want to find row index where the cell value is equal to 1.
data:
'Group1' 'PVT' 'Power' '01-06-2019' [0]
'Group1' 'PVT' 'Power' '01-06-2019' [1]
'Group1' 'PVR' 'VFT' '01-06-2019' [1]
'Group1' 'PMR' 'VGA' '01-06-2019' [1]
I want to get row where the value is equal to 1 in last column. I tried below code but does not work.
Method1:
IndexC = strfind(cell2mat(data{:,end}),'1');
method2:
idx2=strfind(data(:,end),'1');
Both does not worlk.

採用された回答

madhan ravi
madhan ravi 2019 年 6 月 29 日
The last column doesn't seem to be a char:
data(cell2mat(data(:,end))==1,:)
  1 件のコメント
madhan ravi
madhan ravi 2019 年 6 月 29 日
row_indices = find(cell2mat(data(:,end))==1)

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

その他の回答 (0 件)

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by