How to find a substring within a miscellaneous cell array?

4 ビュー (過去 30 日間)
Ed Mendes
Ed Mendes 2020 年 3 月 7 日
コメント済み: Ed Mendes 2020 年 3 月 7 日
Hello
I need to search for a specifig substring within a cell array of different types. Below it is an example.
>> impact_factor(3,:)
ans =
1×8 cell array
Columns 1 through 5
{'Rank'} {'FullJournalTitle'} {'Total Cites'} {[NaN]} {'Journal Impact …'}
Columns 6 through 8
{'Eigenfactor Score'} {[NaN]} {[NaN]}
if I use the full string, the solution could be something like
find(strcmp('FullJournalTitle',impact_factor(3,:)))
However if I try to search for substring such as 'Full' and using either strfind or contains, an error comes out.
Many thanks
Ed

採用された回答

dpb
dpb 2020 年 3 月 7 日
Alternatively, string can convert numerics...
>> contains(string(C),"Full")
ans =
1×8 logical array
0 1 0 0 0 0 0 0
>>
  3 件のコメント
dpb
dpb 2020 年 3 月 7 日
Is a handy feature albeit at the cost of introducing yet another cast. The penchant for the other string functions to return empty or to not be able to handle non-string inputs has always made such lookups a real hassle to work around. Is highly prevalent situation in reading data from spreadsheets and the like that seems, unfortunately, more and more ubiquitous to have to deal with...
Ed Mendes
Ed Mendes 2020 年 3 月 7 日
It seems that we will have to deal with it case by case. I am always worried when matlab needs to read data from spreadsheets. Thank you ever so much for your help.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by