??? Reference to non-existent field 'matlab'.

Dear Matlab users,
In Matlab 2009b, when I save a file that is open in the editor, the save executes successfully while the console returns the error:
??? Reference to non-existent field 'matlab'.
This occurs with no execution of code and does not crash any code that is executing, but returns the error once control is returned to the console. Restarting my system or matlab does not clear the issue.
It is more of a nuisance than anything else, but it would be nice to get to the bottom of it. Any ideas?
Cheers, Jordan

답변 (7개)

Jan
Jan 2012년 3월 27일

2 개 추천

Is this the complete error message? Does:
E = lasterror
reveal the location, which function throws the error?
Does the error appear, if you exclude all user-defined functions from the PATH? If not, one of your functions shadows a function, which is called during saving. It is hard to avoid such problems, because there is no built-in tool to detect such collisions. I've tried to develop such a tool, but the interest in the community is negligible.

댓글 수: 1

Jordan
Jordan 2012년 3월 27일
Hi Jan,
Thanks for the suggestion - that is a great debugging function that I did not know about. In this case it is not too helpful, though. It returns:
message: 'Reference to non-existent field 'matlab'.'
identifier: 'MATLAB:nonExistentField'
stack: [0x1 struct]
I am trying to track down a possible PATH shadowing problem. I don't get any errors immediately after adding my own paths, but the errors begin after my first crash. I'll post again here if I'm able to track this down...

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

Jan
Jan 2012년 3월 27일

2 개 추천

If dbstop if error does not stop Matlab, try:
dbstop if all error

댓글 수: 1

Jordan
Jordan 2012년 3월 28일
Good idea -- but amazingly -- still not catching the error!

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

Matt Tearle
Matt Tearle 2012년 3월 27일

1 개 추천

A shot in the dark, but... your filename isn't something like myfile.matlab.m is it...?

댓글 수: 6

Jordan
Jordan 2012년 3월 27일
Thanks for the suggestion, but no -- I am only working with regular 'function.m' files.
Image Analyst
Image Analyst 2012년 3월 27일
Well how long is this file? Is it too long to simply paste here so people can stop guessing and see your code?
Jordan
Jordan 2012년 3월 28일
Analyst: I don't think posting code would help as the issue is not limited to any one function. For example, I created the function
function imafunction
a=1
return
...and I get the same error when I save the file, though that function does save and execute.
Matt Tearle
Matt Tearle 2012년 3월 28일
And nothing funky in your path names either, right? (Sorry, don't mean to be a dork, but you mentioned something about it happening after you added directories to your path.)
Daniel Shub
Daniel Shub 2012년 3월 28일
@Matt, I think the potential for a funky path, or some other corrupted setting, is a likely culprit.
Malcolm Lidierth
Malcolm Lidierth 2012년 3월 30일
The only accessible reference to MATLAB:nonExistentField seems to be in Tiff.m where the exception is thrown from the MATLAB tifflib code - but that does not help much.

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

Sean de Wolski
Sean de Wolski 2012년 3월 27일

0 개 추천

dbstop if error
Then generate the error and see where it's being called.

댓글 수: 4

Jordan
Jordan 2012년 3월 27일
This works in my normal debugging but strangely, doesn't catch this particular error.
Sean de Wolski
Sean de Wolski 2012년 3월 27일
What is your complete workflow? You have a file open in the editor, you save it, you see the error? Is that all? Do you have something shadowing save?
Jordan
Jordan 2012년 3월 27일
That's right. On further exploration, it seems to start after catching an error with dbstop for the first time. Run program, catch error with dbstop if error, save executed file with changes, see the error.
Strangely, saving files not in the debug function stack only causes errors when NOT in debug mode. That is, if I save a random function file when in the regular console, I get an error. But if I am in debug mode for some unrelated function, no error occurs.
Matt Tearle
Matt Tearle 2012년 3월 28일
How are you saving? Clicking the Editor save icon, ctrl-S, issuing the save command in Command Window, etc? And out of curiosity, what happens if you issue the following commands instead:
foo = matlab.desktop.editor.getActive
foo.save

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

Daniel Shub
Daniel Shub 2012년 3월 28일

0 개 추천

Have you tried deleting/renaming your preferences directory?
Jan
Jan 2012년 3월 28일

0 개 추천

I guess you have shadowed a Java function, which is required for saving. If the hypothetical function "tool.matlab.editor.save" would be used and you have a variable called "tool", the error message should be similar to your oberservations.
Unfortunately I do not know a function, which contains ".matlab". My trial to ask Google failed, because the dots have been converted automagically to spaces even if I include the term ".matlab." in double quotes and Google CodeSearch is down.
Does whos reveal and suspicious candidates?

댓글 수: 3

Sean de Wolski
Sean de Wolski 2012년 3월 28일
autononmagic!
Daniel Shub
Daniel Shub 2012년 3월 28일
I am not sure you can overload java functions this way. I created a dummy function java.m and added it to my path and made its directory the current working directory. The call f = java.io.File('MyFile') does not seem to use the overloaded function.
Jan
Jan 2012년 3월 29일
I'm not sure also. It is statistical guessing, because unintentionally overloaded functions have been a source of weird problems repeatedly.

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

Andrew Meintz
Andrew Meintz 2021년 2월 10일

0 개 추천

I had the same issue and when I clean the build folder from previous generated file. It works.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2012년 3월 27일

답변:

2021년 2월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by