How to delete 'mat 'files

7 ビュー (過去 30 日間)
sri Jagarlmudi
sri Jagarlmudi 2018 年 9 月 18 日
コメント済み: sri Jagarlmudi 2018 年 9 月 18 日
Hi, I have 20 files with '.dat' and '.mat' extension in one folder. And I have problem with deleting files with extension '.mat'. I have written this in order to delete mat files
delete(any(size(dir(['DataPath/*.mat' ]),1)))
after deleting one '.mat ' it showing error
Error using delete
Argument must contain a string.
Error in myfile(line 81)
delete(any(size(dir(['DataPath/*.mat' ]),1)))
Can any one please tell me how to solve this problem
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 9 月 18 日
can you share the code?
MF
MF 2018 年 9 月 18 日
編集済み: MF 2018 年 9 月 18 日
Does this topic help you solve your problem - how to delete mat file? If not, let me know.

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

採用された回答

OCDER
OCDER 2018 年 9 月 18 日
DataPath = 'C:\Blah\User\Blah';
delete(fullfile(DataPath, '*.mat'))
  1 件のコメント
sri Jagarlmudi
sri Jagarlmudi 2018 年 9 月 18 日
thank you it worked

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 9 月 18 日
delete(any(size(dir(['DataPath/*.mat' ]),1)))
I would be extremely surprised (stunned) if that worked. The any function returns a logical value, so what you're running is:
delete(true) % or
delete(false)
If you want to delete ALL the files with the .mat extension in that subdirectory, see the first example on the delete documentation page. If you want to delete some of the files, explain in more detail (in words, not code) what you want to do and we may be able to help you do that.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by