Using load function unexpectedly deleting original .mat file

When I load variables into the workspace from a .mat file, MATLAB then deletes the original file.
Does anybody know why this is happening?
Thank you.

4 commentaires

Stephen23
Stephen23 le 23 Août 2017
Modifié(e) : Stephen23 le 23 Août 2017
@Sam Firminger: please show us the complete output of this command:
which load -all
Please show us the text in a new comment, along with the relevant code that you are using when this bug occurs. Please post text and not screenshots.
Hello, I was trying to post the full output but my comment was getting flagged for potential spam. Here is the first part of the output...
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\general\load)
I have circumvented the issue at the moment by saving the workspace variables back to a file of the same name after I have finished with them, however would like to know why this is occuring. It's never happened before.
My code that I'm using with it is:
for i = 1:length(list)
filename = char(list(i)) ;
disp(filename);
%ensure not to go out of bounds
if i ~= length(opFlowVariables)
load(filename) ;
main(vx, vy, i, outputFolder) ;
end
end
Here, I am just going through all the files, loading the variables 'vx' and 'vy' and using them in 'main'.
Is that the bad code, or the circumvented/working code? I don't see any line of code that would delete a .mat file, unless main() does it internally.
Hello,
I found the bug. When I was saving a variable to a file elsewhere in the code, I was using the same filename which caused some issues. Nevertheless thank you for your help.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Tags

Commenté :

le 25 Août 2017

Community Treasure Hunt

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

Start Hunting!

Translated by