You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the string macro mat"" I frequently get "failed to get variable ans from MATLAB session" error. This happens even though I am suppressing Matlab output with ;. It happens in various situations, but this is the first reliably reproducible example I have been able to make:
Put this in a file Foo.m somewhere in your path:
classdef Foo < dynamicprops
end
Then run:
julia> using MATLAB
julia> mat"f = Foo();"
inary
julia> mat"addprop(f, 'bar');"
Error using save
Unable to save variable 'ans' of class 'meta.DynamicProperty' to STDIO.
ERROR: MATLAB.MEngineError("failed to get variable ans from MATLAB session")
Stacktrace:
[1] get_mvariable(::MSession, ::Symbol) at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:164
[2] get_mvariable at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:168 [inlined]
[3] get_variable(::Symbol) at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:170
[4] top-level scope at /home/DNF/.julia/packages/MATLAB/cVrxc/src/matstr.jl:169
[5] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088
The dynamic property 'bar' is successfully created.
Why is the word 'inary' printed to output after creation of the object? This happens a lot.
Update: This seems to be a general issue for handle classes, whenever a method or function returns the object itself. Here's (possibly) minimal example:
Foo.m:
classdef Foo < handle
end
The error occurs when we don't capture the returned object:
julia> mat"f = Foo();" # This is ok
julia> mat"Foo();" # This is not ok
inary
Error using save
Unable to save variable 'ans' of class 'Foo' to STDIO.
ERROR: MATLAB.MEngineError("failed to get variable ans from MATLAB session")
Stacktrace:
[1] get_mvariable(::MSession, ::Symbol) at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:164
[2] get_mvariable at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:168 [inlined]
[3] get_variable(::Symbol) at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:170
[4] top-level scope at /home/DNF/.julia/packages/MATLAB/cVrxc/src/matstr.jl:169
[5] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088
This doesn't work either:
julia> mat"Foo();"; # note the extra ;
At least there is a workaround: capture the output in a variable. But what's up with the 'inary' ouput?
Using the string macro
mat""
I frequently get "failed to get variable ans from MATLAB session" error. This happens even though I am suppressing Matlab output with;
. It happens in various situations, but this is the first reliably reproducible example I have been able to make:Put this in a file
Foo.m
somewhere in your path:Then run:
'bar'
is successfully created.MATLAB.jl v0.7.3
MATLAB Version: 9.8.0.1417392 (R2020a) Update 4
The text was updated successfully, but these errors were encountered: