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일

0 개 추천

DataPath = 'C:\Blah\User\Blah';
delete(fullfile(DataPath, '*.mat'))

추가 답변 (1개)

Steven Lord
Steven Lord 2018년 9월 18일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

태그

질문:

2018년 9월 18일

댓글:

2018년 9월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by