octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Incompatibility between Matlab and Octave with respect to function handl


From: avlas
Subject: Incompatibility between Matlab and Octave with respect to function handles
Date: Sun, 18 Mar 2018 10:10:10 -0400

Dear Octave devs,

I recently found an issue when trying to load a mat file in octave:

Part 1: The original mat file was created in macOS and contained a function 
handle to a particular m-file. 

Octave couldn't load tha mat file and displayed an error about not being able 
to find the m-file. Matlab loaded the mat file with no error (but the function 
handle was emptied; see Part 2 below). R hanged up using all CPU resources.

Conclusions 1: 

- Octave couldn't load any data, but was informative about the m-file issue (it 
could have been even more informative if it would inform about the particular 
variable in the mat file causing the issue). 
- Matlab cared only about the data and not at all about the missing m-file.

Part 2: Trying to debug the above issue I realized that another related but 
different issue is when one defines pseudo anonymous functions with no content.

Matlab allows to do:

"
pseudo_anonymous_function = @afun 

pseudo_anonymous_function = 
function_handle with value: 
@afun 
"
Octave doesn't like those:

" 
pseudo_anonymous_function = @afun 
error: @afun: no function and no method found  
"

Conclusion 2:

So, when trying to load a mat file from Matlab that contains one of those empty 
function handles, the same sort of error is displayed. Octave couldn't load any 
data, and informed instead about the function handle issue (it wasn't 
informative about the particular variable in the mat file causing the issue 
though).

Final discussion:

- Whether or not Octave should allow dealing with function handles as Matlab 
does (wrt missing m-files and/or empty function handles)

- More importantly perhaps, whether it would make sense to extract as much data 
from a mat file as possible, as well as to display more informative errors, 
i.e., displaying the variables causing them (var 1: error 1; var 2: error 2... 
I'm not an Octave dev, so I don't know the internals, but I think this could be 
in principle achieved with a loop for the number of variables in the mat file, 
and using try/catch inside the loop).

Currently, only the (first encountered) error is shown, no relation to any 
variable is displayed and no data is loaded in the workspace. From an octave 
user point of view, these function handles may be not that relevant, however 
these issues do not allow to have access to other relevant data in the mat file.

What do you think?

Btw, this relates to bug https://savannah.gnu.org/bugs/?53363 (Note that the 
title and info in that bug are not as clear as it is written here because I 
submitted the bug, and wrote comments in it, while I was trying to figure out 
what was going on).

Thanks and best,

...
a.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]