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

18 次查看(过去 30 天)
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.

回答(2 个)

Harry Vancao
Harry Vancao 2018-12-5
编辑:Harry Vancao 2018-12-5
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 个评论
Steven Lord
Steven Lord 2018-12-5
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

请先登录,再进行评论。


Jacob Smith
Jacob Smith 2021-9-13
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

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by