separate data from file

1 回表示 (過去 30 日間)
Jay Hanuman
Jay Hanuman 2016 年 11 月 23 日
編集済み: KSSV 2016 年 11 月 23 日
I attached data file. data is in format of
source _ip:source_port->destination_ip:destination_port
I want to take out only source_ip data from that, how to do.
  2 件のコメント
KSSV
KSSV 2016 年 11 月 23 日
No file attached..
Jay Hanuman
Jay Hanuman 2016 年 11 月 23 日
I forgot, now I attached

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

採用された回答

KSSV
KSSV 2016 年 11 月 23 日
編集済み: KSSV 2016 年 11 月 23 日
load('n0 1.mat') ;
s = VarName6 ;
idx = strfind(s, ':');
idx = cell2mat(idx) ;
idx = idx(:,1)-1 ;
iwant = cellfun(@(x,idx) x(1:idx),s,num2cell(idx), 'UniformOutput', false) ;
Or
load('n0 1.mat') ;
s = VarName6 ;
s1 = regexp(s,':','split') ;
iwant = cellfun(@(x) x{1}(:)',s1, 'UniformOutput', false) ;

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 11 月 23 日
regexp() probably
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 11 月 23 日
Or possibly strsplit

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

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by