converting cell to str

4 ビュー (過去 30 日間)
Mahesh Vibhute
Mahesh Vibhute 2015 年 9 月 2 日
コメント済み: Mahesh Vibhute 2015 年 9 月 3 日
Hi.
I am trying to load a bunch of log files, and then find certain keywords in it.
C is the cell containing the 40 input files in which i want to find certain keywords.
iscellstr(C) = 0
Since i cannot use C in strfind, i have to convert it into C2 as:
C2 = [C{:,i}]
However, here's the main problem. C contains all the 40 files i want to read, but C2 contains only one, the 40th file.
Any suggestions about the conversion will be appreciated.
Thanks in advance,
Mahesh

採用された回答

Greig
Greig 2015 年 9 月 3 日
You don't need to convert to a strings, try using cellfun instead. For example,
C2 = cellfun(@(x) strfind(x, 'MyPattern'), C, 'UniformOutput', 0);
This returns a cell that contains the indices for each element of C where "MyPattern' is found. Many may be empty, so this is why UniformOutput is specified as zero (i.e., non-uniform output).
You may need to use something like
cellfun(@isempty, C2)
and cell2mat in the final processing steps, depending on what you are want to do after.
  1 件のコメント
Mahesh Vibhute
Mahesh Vibhute 2015 年 9 月 3 日
That worked! Thanks a lot!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by