Alicia
Alicia

Reputation: 37

How to delete a file whose name is given by a character array?

I want to delete a file with variables in the file name. But MATLAB doesn't seem to recognize the file name when using delete. Can anyone help me?

ratio=1;
a=2;
nameoffile3=['r' num2str(ratio) '_a' num2str(a) '.txt'];
delete nameoffile3

Upvotes: 1

Views: 372

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

To delete a file whose name is given by a character array, use delete with parenthesis () i.e.

delete(nameoffile3)

Upvotes: 1

Related Questions