Cannot open a structure file in Matlab

Hello,
I'm operating Matlab2018a on a Windows 10 machine. I can create structure files, but cannot open them. I get this warning/error:
Warning: Unexpected end-of-file while reading compressed data
Error using load
Cannot read file Y:\....filneame.mat
The drive that I'm saving and opening from is a network drive. I have read/write permissions on this drive and can read other non-structure files with no issues.
Is there a solution for this?
Thanks.

댓글 수: 11

If you write the same data to a local hard drive, do you have the same problem?
Shannon
Shannon 2020년 6월 26일
No, no problems when saving to a local drive.
What kind of network drive is it? For example is it a Windows "net map" of Microsoft OneDrive to a drive letter? Is it NTFS? SMB ?
Shannon
Shannon 2020년 6월 26일
I'll check with the administrators as to what type network drive it is.
Shannon
Shannon 2020년 6월 26일
It is NTFS.
I made a mistake in asking about NTFS, in that NTFS is not a network filesystem. I meant to ask about NFS; https://en.wikipedia.org/wiki/Network_File_System#NFSv3
Unfortunately I seem to have lost track of which technology is being commonly used for sharing files in Windows networks these days.
Shannon
Shannon 2020년 6월 26일
편집: Shannon 2020년 6월 26일
Ok - I'm pretty sure it's NFS, but I will check that.
UPDATE - nope, I was wrong, it's SMB.
Fangjun Jiang
Fangjun Jiang 2020년 6월 26일
My experience is that I need to go to Windows Explorer to make sure the Y: drive is connected first.
Shannon
Shannon 2020년 6월 26일
It is connected.
I find hints that the configuration of the smb server and related technologies can affect reliability, but there are a lot of different ways to configure to meet different goals and network configurations, and my decade old peripheral experience does not leave me qualified to advise on current systems.
I don't expect that the problem lies in MATLAB... but MATLAB might be using the network in ways that are not typical for other network work in your organization.
One thing that MATLAB is known to struggle with is differences in time stamp between server and client, as it examines file update times as part of path management. That would tend to affect source files more than mat files.
There was a problem a few releases ago having to do with cache synchronization between OneDrive and MATLAB. It might be worth looking up the details to see if there could be a similar issue in your configuration.
Shannon
Shannon 2020년 6월 26일
That's an understandable issue. I'll see if I can find a work-around. Thanks for your help.

댓글을 달려면 로그인하십시오.

답변 (1개)

Monisha Nalluru
Monisha Nalluru 2020년 7월 10일

0 개 추천

The reason for this error might be due to MAT file corruption in the network drive.
Another indication of the MAT file being corrupt are error messages related to ‘HDF5’ appearing in MATLAB Command Window/Linux or MacOS Terminal/Windows Command prompt.
You can try to recover the non-corrupt portions or individual variables in the mat file using matfilecommand.
Consider for example that 'test.mat' has a variable 'v' that is unreadable. You can first get the size of this variable using the 'size' function as follows:
m=matfile('test.mat');
size(m,v) ans= 6 100
This tells us that the variable 'v' in 'test.mat' is a 2-D array which has 6 rows and 100 columns (a total of 600 values). You can then try to read the 'non-corrupt' values in 'v' and store them in a new array 'vRec' as follows :
vRec = zeros(6,100); % pre-allocate for efficiency
for i=1:6
for j=1:100
try
vRec(i,j) = m.v(i,j); % store the value if it is not corrupt;
catch
vRec(i,j) = NaN; % if the value is corrupt/unreadable store 'NaN;
disp([int2str(i) ',' int2str(j) ' is unreadable.']); % display the indices of the unreadable elements
end
end
end
The above code will try to read all the 'non-corrupt' values in 'v' and store them in 'vRec'. The corrupt values in 'v' will be stored as 'NaNs'

댓글 수: 4

Shannon
Shannon 2020년 7월 13일
편집: Shannon 2020년 7월 13일
That doens't solve the problem. When I use matfile, what is loaded from the network drive is only the properties of the structure file, which is the file name, and "Writable" as false. Could there be an issue with the way that the files are saved when using the network drive?
(Note - there are no issues when I save and load files the same way when on the local drive).
Writeable would be 0 for all -v7 .mat files; it can only be true for -v7.3 .mat files.
Shannon
Shannon 2020년 7월 13일
Correction - "Writable" is "false".
Hi Shannon,
Can you check by saving the files in these version and check the load command, as I am not able to reproduce the error at my end.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Cloud File Storage에 대해 자세히 알아보기

질문:

2020년 6월 25일

댓글:

2020년 7월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by