Why can't I load a .mat file from a shared network location?

18 views (last 30 days)
I wrote a script that loads data from "ai.mat". I use a loop to iterate through my data folders, and for each folder I cd() to the folder, load the second component of ai.mat, perform some calculations, then cd() back to the folder I operate out of (where the .m file is saved).
% load data from ai.mat
vars = whos('-file','ai.mat');
load('ai.mat',vars(2).name);
I have no trouble performing this routine when the data folders are on my local computer. However, when I try to perform the same routine on the same data folders that are copied to a shared network location, I am unable to load ai.mat even though Matlab thinks it exists (e.g. I can cd() to the shared folder, I see ai.mat when I type dir, and exist('ai.mat') returns 2). For reasons I won't go into, it's advantageous for me to be able to access the files from the shared location rather than my local computer. The shared location is mapped to my local machine as "Z:\". I get this error message: "Error using load: Cannot read file Z:\PATH\ai.mat."
Can anyone identify why I can't access these .mat files on the shared location? Thanks.

Answers (2)

Harry Vancao
Harry Vancao on 5 Dec 2018
Edited: Harry Vancao on 5 Dec 2018
The most likely cause for this is that you may not have permissions to read these files. Please make sure that you have read access to the directory that ai.mat is located in.
  1 Comment
Steven Lord
Steven Lord on 5 Dec 2018
Another possibility is that the ai.mat file in the network location has been corrupted or is a different type of file that happens to have the .mat extension. To test this possibility, if you copy the ai.mat file to a local temporary directory outside MATLAB (using Windows Explorer) can you load it from that temporary directory?
winopen Z:\PATH
winopen(tempdir)
cd(tempdir)
Copy the file then
load ai.mat

Sign in to comment.


Jacob Smith
Jacob Smith on 13 Sep 2021
We've been having a similar issue and can confirm it's not because of the above answers. Strangely, using the 'edit file.m' function loads it fine, but otherwise it just cooks itself. Only happens on a shared network drive.
An answer to this would be fab as there is something real weird going on

Categories

Find more on Search Path in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!