Info

This question is closed. Reopen it to edit or answer.

Matfile isn't always finding the file

1 view (last 30 days)
Jonathan Conte
Jonathan Conte on 24 Feb 2017
Closed: MATLAB Answer Bot on 20 Aug 2021
I'm having a problem using "matfile". There is an inconsistent error, as I described here http://stackoverflow.com/questions/42098631/matfile-isnt-loading-the-structures-field-names
I narrowed it down to the object, matlab.io.MatFile, I get an error in the line
[varargout{1:nargout}] = fcnHan('-file', ...
obj.Properties.Source, varargin{:})
Saying:
Error using whos
Could not find
\\bontempi...[skip]...NexusMarkersProcessed.mat.
It's weird because it can load just fine, here's some output from my command window during a debug:
tes=whos(obj.Properties.Source)
tes =
0×1 empty struct array with fields:
name
size
bytes
class
global
sparse
complex
nesting
persistent
>> ves=load(obj.Properties.Source)
ves =
struct with fields:
Patient10: [1×2 struct]
Patient11: [1×4 struct]
Patient3: [1×2 struct]
Patient5: [1×2 struct]
Patient6: [1×1 struct]
Patient7: [1×2 struct]
Patient9: [1×2 struct]
Why can't "whos", see the fieldnames in the matfile object? Why isn't the matfile object loading in the structure?It may have to do with inconsistent behaviour of "exist" on the line:
itDoes = exist(obj.Properties.Source,'file');
Which when I set a breakpoint there sometimes finds the file, sometimes does not. This may be due to accessing a network drive? Please let me know if there is any more info you need. Thanks
  6 Comments
Jonathan Conte
Jonathan Conte on 27 Feb 2017
... my eyes have been opened to the impossibility. Thanks. I'll see if there is a workaround: copying the files to the C: drive at the beginning of the program (assuming I can do that reliably), running it, and finally deleting the temporary copies at the end of the script.
Walter Roberson
Walter Roberson on 27 Feb 2017
Copying is almost always reliable in such situations (provided the file is not being written to by a different process at the same time it is being copied.)

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!