how to delete mat file
35 ビュー (過去 30 日間)
古いコメントを表示
i have saved a variable by using
save('fp_database.mat','data');
i want to delete this file so i tried
delete('fp_database.mat')
now even i load it by load('fpnn_database.mat');its values are displayed and not deleted
please tell how to delete it
4 件のコメント
採用された回答
Jan
2013 年 1 月 2 日
Using Matlab's posibility to search a file in the complete list of folders in the path leads to such strange effects. It is recommended to use absolute file names instead:
File = fullfile(cd, 'fp_database.mat');
save(File,'data');
...
delete(File);
disp(exist(File, 'file'))
The current directory can be modified by GUI or TIMER callbacks, such that absolute file names are more secure in general also.
2 件のコメント
Image Analyst
2013 年 1 月 2 日
編集済み: Image Analyst
2013 年 1 月 2 日
I second Jan's suggestion. Using full filenames where you specify exactly what both the folder and the base filename is preferable. Robust code will make liberal use of fullfile() and exist(), and not use cd as per the FAQ. (Using cd like Jan did is fine, since it doesn't actually change the directory, but I use "pwd" in cases like that.) That way you always know exactly what folder you're looking in and what file you're dealing with and there are no uncertainties about what the current directory may be or what the search path may be.
その他の回答 (2 件)
Azzi Abdelmalek
2013 年 1 月 2 日
編集済み: Azzi Abdelmalek
2013 年 1 月 2 日
Try this
a=1:10;
save('fp_database','a')
delete('fp_database.mat')
clear
load('fp_database')
a
0 件のコメント
Malcolm Lidierth
2013 年 1 月 2 日
Looks like you have several copies in different folders on the MATLAB path. Delete only deletes the first. Try
which ('fp_database.mat')
after delete to find the 2nd.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Search Path についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!