フィルターのクリア

find() returns content of {1×0 double} cell array

2 ビュー (過去 30 日間)
chlor thanks
chlor thanks 2020 年 4 月 15 日
コメント済み: chlor thanks 2020 年 4 月 17 日
fullfiles have a list of file paths, RAW has the substrings I like to search for in the file paths.
I want the output AllIndex to be indexes of those found files.
AllIndex={};
for k = 1 : length(RAW)
IndexRAW = strfind(fullfiles, char(RAW(k)));
Index = find(~(cellfun('isempty', IndexRAW)));
AllIndex{end+1}=Index
end
but my output is
AllIndex =
1×8 cell array
{1×0 double} {1×0 double} {1×0 double} {1×0 double} {1×0 double} {1×0 double} {1×0 double} {1×0 double}
its content shown in Editor as
[] [] [] [] [] [] [] []
Please help! Thanks!!
  3 件のコメント
chlor thanks
chlor thanks 2020 年 4 月 15 日
say my fullfiles is = {'\\path\143'} {'\\path\204'} {'\\path\450'}
RAW = {'450'} {'143'}
I want the output AllIndex to be = 3 1
Stephen23
Stephen23 2020 年 4 月 15 日
"Result of strfind is integer arrays but you are trying to use cellfun"
The MATLAB documentation states:
"If str is a cell array of character vectors or a string array, then strfind returns a cell array of vectors of type double."

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

採用された回答

darova
darova 2020 年 4 月 15 日
What about simple for loops?
ffile = {'\\path\143' '\\path\204' '\\path\450'};
RAW = {'450' '143'};
allind = zeros(size(RAW));
for i = 1:numel(RAW)
for j = 1:numel(ffile)
if strfind(ffile{j},RAW{i})
allind(i) = j;
break;
end
end
end
allind
  4 件のコメント
darova
darova 2020 年 4 月 15 日
  • but for some reason it doesnt work with my (fullfiles 1×101 cell array and RAW 8×1 cell array)
Can you show? I don't believe
chlor thanks
chlor thanks 2020 年 4 月 17 日
I cannot really do that... I am running out of ideas as well, but thanks for the alternatives

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

その他の回答 (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