Asterisk wildcard doesn't work with fullfile

27 ビュー (過去 30 日間)
Balázs Szabó
Balázs Szabó 2020 年 8 月 11 日
コメント済み: Balázs Szabó 2020 年 8 月 11 日
I'm trying to get the file names in a folder that end in a specific way (100MVC.otb+). AFAIK the way to do this is like this:
signals=dir(fullfile(signalDir,'*100MVC.otb+'));
But for some reason it seems like it can't understand the wildcard and it never finds a match. The same happens when I try to list the files:
>> ls(fullfile(signalDir,'*100MVC.otb+'))
No matches for pattern 'Test02_20200522\*100MVC.otb+'.
Any idea why it's not working, or how to solve it?

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 8 月 11 日
編集済み: Cris LaPierre 2020 年 8 月 11 日
I mocked up a folder inside my current directory named "Test02_20200522" with contents "file1_100MVC.otb+" to "file4_100MVC.otb+".
Your code works so long as I don't change my current directory. When I do, it can no longer find the folder and returns the same error message you are seeing. To avoid this, I recommend using the full path name for signalDir, not just the final folder name.
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 8 月 11 日
編集済み: Walter Roberson 2020 年 8 月 11 日
On Mac, it just works without an problem.
I wonder if this might happen to work:
signals=dir(fullfile(signalDir,'*100MVC.otb\+'));
or
signals=dir(fullfile(signalDir,'*100MVC.otb*'));
Balázs Szabó
Balázs Szabó 2020 年 8 月 11 日
Thanks, that was the issue. It works with the full path

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Name Construction についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by