[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #47763] Loading a function handle variable fro
From: |
Guillaume |
Subject: |
[Octave-bug-tracker] [bug #47763] Loading a function handle variable from a MAT-file |
Date: |
Fri, 22 Apr 2016 17:11:52 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 |
URL:
<http://savannah.gnu.org/bugs/?47763>
Summary: Loading a function handle variable from a MAT-file
Project: GNU Octave
Submitted by: gyom
Submitted on: Fri 22 Apr 2016 05:11:51 PM GMT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: None
Status: None
Assigned to: None
Originator Name: Guillaume
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux
_______________________________________________________
Details:
When loading a MAT-file containing a function handle, it doesn't work if the
path to the function has changed (but is still in the function search path).
See the following piece of code:
>> % have foo.m in /tmp
>> type /tmp/foo.m
>> addpath /tmp
>> % create foo.mat with Matlab
>> cd ~
>> address@hidden;
>> functions(f)
>> save foo.mat f -v6
>>
>> % load when file is where expected and in the path
>> addpath /tmp
>> load foo.mat
>> functions(f)
>> f()
>>
>> % load when file is where expected but not in the path
>> rmpath /tmp
>> load foo.mat
>> functions(f)
>> f()
>>
>> % load when file is elsewhere in the path
>> movefile('/tmp/foo.m',pwd)
>> load foo.mat
>> functions(f)
>> f()
Octave does:
>> % load when file is where expected and in the path
>> addpath /tmp
>> load foo.mat
>> functions(f)
ans =
scalar structure containing the fields:
function = foo
type = simple
file = /tmp/foo.m
>> f()
Hello
>> % load when file is where expected but not in the path
>> rmpath /tmp
>> load foo.mat
>> functions(f)
ans =
scalar structure containing the fields:
function = foo
type = simple
file = /tmp/foo.m
>> f()
Hello
>> % load when file is elsewhere in the path
>> movefile('/tmp/foo.m',pwd)
ans = 1
>> load foo.mat
error: no such file, '/tmp/foo.m'
>> functions(f)
ans =
scalar structure containing the fields:
function = foo
type = simple
file = /tmp/foo.m
>> f()
error: foo: no longer valid function handle
while Matlab does:
>> % load when file is where expected and in the path
>> addpath /tmp
>> load foo.mat
>> functions(f)
ans =
function: 'foo'
type: 'simple'
file: '/tmp/foo.m'
>> f()
Hello
>> % load when file is where expected but not in the path
>> rmpath /tmp
>> load foo.mat
>> functions(f)
ans =
function: 'foo'
type: 'simple'
file: ''
>> f()
Undefined function or variable 'foo'.
>> % load when file is elsewhere in the path
>> movefile('/tmp/foo.m',pwd)
>> load foo.mat
>> functions(f)
ans =
function: 'foo'
type: 'simple'
file: '/home/foo/foo.m'
>> f()
Hello
So Octave finds the function when it's not in the search path but in its
initial location (Matlab doesn't, appropriately) and doesn't find the function
if it's in the search path but not in its initial location.
I attach the foo.mat file created with Matlab to this bug report.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Fri 22 Apr 2016 05:11:51 PM GMT Name: foo.mat Size: 832B By: gyom
<http://savannah.gnu.org/bugs/download.php?file_id=36980>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?47763>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #47763] Loading a function handle variable from a MAT-file,
Guillaume <=
- [Octave-bug-tracker] [bug #47763] Loading a function handle variable from a MAT-file, Guillaume, 2016/04/22
- [Octave-bug-tracker] [bug #47763] saving a function handle to user function saves full path, Mike Miller, 2016/04/22
- [Octave-bug-tracker] [bug #47763] saving a function handle to user function saves full path, Guillaume, 2016/04/22
- [Octave-bug-tracker] [bug #47763] saving a function handle to user function saves full path, Guillaume, 2016/04/22
- [Octave-bug-tracker] [bug #47763] saving a function handle to user function saves full path, Mike Miller, 2016/04/22
- [Octave-bug-tracker] [bug #47763] load: function handle to user function uses full path, should just search load path, Mike Miller, 2016/04/22
- [Octave-bug-tracker] [bug #47763] load: function handle to user function uses full path, should just search load path, Guillaume, 2016/04/25
- [Octave-bug-tracker] [bug #47763] load: function handle to user function uses full path, should just search load path, Guillaume, 2016/04/25