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 Comments

@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.

Sign in to comment.

Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Asked:

on 23 Aug 2017

Commented:

on 25 Aug 2017

Community Treasure Hunt

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

Start Hunting!