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

조회 수: 18 (최근 30일)
Ann Hickox
Ann Hickox 2018년 11월 30일
답변: Jacob Smith 2021년 9월 13일
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