フィルターのクリア

How to filter based on matching string

36 ビュー (過去 30 日間)
Mekala balaji
Mekala balaji 2018 年 10 月 11 日
コメント済み: Mekala balaji 2018 年 10 月 11 日
Hi,
I have below cell array, and I want to calculate the summation of the data in column 3 for matching names in column 1 & column 2. I also want to get the indices of matching rows.
Type Status Rank
Autostable Success 23
Auto Failure 56
Manual Failure 12
Manual Disconnect 45
Manual Success 45
Reinitiate Success 42
Summation of rank if(output1):
Type: Auto OR Autostable
Status:Success
Summation of rank if(Output2):
Type: Auto OR Autostable
Status:Success or Failure
Summation of rank if(Output3):
Type: Auto OR Autostable OR Manual
Status:Success
Summation of rank if(Output4):
Type: Auto OR Autostable OR Manual
Status:Success OR Failure OR Disconnect
Desired Outputs:
Output1:23
Output2:79
Output3:197
Output4:367

回答 (1 件)

KSSV
KSSV 2018 年 10 月 11 日
Convert your cell arrays into table and use:
Type = {'Autostable' ; 'Auto' ; 'Manual' ; 'Manual' ; 'Manual' ; 'Reinitiate' } ;
Status = { 'Success' ; 'Failure'; 'Failure' ; 'Disconnect' ;'Success' ; 'Success'} ;
Rank = [23 56 12 45 45 42]' ;
T = table(Type,Status,Rank) ;
T(contains(T.(1),'Manual'),:)
  3 件のコメント
KSSV
KSSV 2018 年 10 月 11 日
Have a look on celltotable.
Mekala balaji
Mekala balaji 2018 年 10 月 11 日
Sir,
Can we match multiple strings like "Auto" or "Autostable" Scenario2: manual or Auto in the same statement:T(contains(T.(1),'Manual'),:)

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

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by