Comments (19)
where does it save if you run the file from matlab alone?
from matlab.jl.
check the directory
julia> mat"pwd"
"C:\\Program Files\\MATLAB\\R2016b"
from matlab.jl.
One option is to start the MSession in the julia start directory
i.e. inserting ccall(engfunc(:engEvalString), Cint, (Ptr{Void}, Ptr{UInt8}), ep, #directory of julia start)
from matlab.jl.
good catch, looks like locate wasn't updating as fast as I thought it would (also, thanks for the fast turn around!). The minimal example does what it's supposed to.
I'm running the original code to see if I can get it to reproduce the error (the first time gave an error message along the lines of "failed to get ans from a MATLAB session", but further calls were silent).
from matlab.jl.
Yep still getting errors on the real code. The Julia error is MATLAB.MEngineError "failed to get the variable ans from a MATLAB session". while the MATLAB error is
{Error using save Variable 'ans' of class 'matlab.graphics.primitive.Surface' cannot be saved to STDIO.
}
from matlab.jl.
Strange, I can't reproduce. Are you sure you can't reproduce those errors from matlab alone?
from matlab.jl.
the code above works fine- I have significantly messier code that is producing the above errors when called through Julia. The command is
mat"plotImportantScat($(β), $(Sname), $(CLASSNAMES), 'randoCal')"
where plotImportantScat
is the function which calls export_fig, and \beta, Sname, and CLASSNAMES are all Julia variables. I ran this function (there's ~170 lines, which is why I haven't posted it) on different data in MATLAB earlier today, and it gave no errors.
Running it again, I've found that if I don't return the handles for the plot, it doesn't return the error and saves. Perhaps there's something with the way MATLAB interacts with csh that causes this error?
from matlab.jl.
So I can't seem to reproduce on my linux machine
Also on linux it seems that the path will open by default in the current directory (not the case for windows)
julia> using MATLAB
julia> y = linspace(2., 3., 500)
500-element LinSpace{Float64}:
2.0,2.002,2.00401,2.00601,2.00802,2.01002,2.01202,2.01403,2.01603,…,2.98597,2.98798,2.98998,2.99198,2.99399,2.99599,2.998,3.0
julia> mat"plot($(y))"
>> >> >> Warning: MATLAB has disabled some advanced graphics rendering features by
switching to software OpenGL. For more information, click <a
href="matlab:opengl('problems')">here</a>.
julia> mat"export_fig(gcf,'test.png')"
>> >> >> Warning: MATLAB cannot use OpenGL for printing when started with the
'-nodisplay' option.
> In inputcheck (line 160)
In print (line 41)
In print2array (line 183)
In export_fig (line 518)
julia> ^C
from matlab.jl.
which version of matlab and which julia version and are you on master MATLAB.jl
?
from matlab.jl.
R2015a, and I believe I'm on master. I updated earlier today.
Apologies for mis-identifying the source of the error earlier. Here's a block of code that should reproduce the error. define the following function in Matlab (I did it using a file in the current Matlab directory)
function handel = test(bar)
handel = plot(bar)
end
then call it in julia using
using MATLAB
x = linspace(-10., 10., 500)
mat"test($(x))"
this returns the error
MATLAB.MEngineError "failed to get the variable ans from a MATLAB session"
in get_mvariable at MATLAB/src/engine.jl:136
in get_variable at MATLAB/src/engine.jl:143
{Error using save
Variable 'ans' of class 'matlab.graphics.chart.primitive.Line' cannot be saved
to STDIO.
}
from matlab.jl.
cc @simonster
from matlab.jl.
Presumably you are on a linux machine? I'm not familiar with csh, but maybe it's an older version or something? The one I tried is ii csh 20110502-2.1ubunt amd64 Shell with C-like syntax
from matlab.jl.
@dsweber2 what happens when you try julia> eval_string("test($x)")
from matlab.jl.
For me
julia> eval_string("test($x)")
handel =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.8000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1�500 double]
YData: [1�500 double]
ZData: [1�0 double]
Use GET to show all properties
from matlab.jl.
I'm not at all familiar with csh, but was going off of the readme's description of what the interface with matlab is. I am on Ubuntu 16.04.1 LTS, and julia v0.5.0
interesting, when I ran eval_string("test($(x))")
I got slightly more (but effectively the same):
>>
handel =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1x500 double]
YData: [1x500 double]
ZData: [1x0 double]
Use GET to show all properties
ans =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1x500 double]
YData: [1x500 double]
ZData: [1x0 double]
Use GET to show all properties
comparing this to when I run mat"test($(x))"
at a terminal:
>> >> >>
handel =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1x500 double]
YData: [1x500 double]
ZData: [1x0 double]
Use GET to show all properties
Error using save
Variable 'ans' of class 'matlab.graphics.chart.primitive.Line' cannot be saved
to STDIO.
ERROR: MATLAB.MEngineError("Failed to get the variable ans from a MATLAB session.")
in get_mvariable(::MATLAB.MSession, ::Symbol) at /home/david/.julia/v0.5/MATLAB/src/engine.jl:136
in get_variable(::Symbol) at /home/david/.julia/v0.5/MATLAB/src/engine.jl:143
from matlab.jl.
The mat
string literal tries to return the result of the MATLAB expression. The problem is that MATLAB apparently does not always support getting all types of objects via the API, so in this case it is throwing an error. Not sure what the correct behavior is here; we could warn or just return nothing
.
from matlab.jl.
@simonster currently it spits an ERROR: ArgumentError: Unsupported kind of variable.
Perhaps a warning is more appropriate and to return nothing?
from matlab.jl.
I see. For my usage, at least, a warning that recommends using eval_string instead would be sufficient, since I wasn't planning on trying to edit the plothandles in Julia anyways.
from matlab.jl.
julia> mat"pwd"
"C:\Program Files\MATLAB\R2016b"
I think it is better that automatically you'll move to the user path by (MATLAB syntax) - cd(userpath())
.
I actually think it will be the most useful to have a dedicated package to use MATLAB's plotting library. Just like PyPlot.jl
. MATLAB interactive figures are something we can't (At least I couldn't find how) reproduce in Julia (As Matplotlib still doesn't have this smooth operation).
from matlab.jl.
Related Issues (20)
- Automatic COM server registration on Windows HOT 11
- TagBot trigger issue HOT 5
- mxarray on partially initialized structs
- UndefRefError on windows HOT 3
- Error precompiling MATLAB.jl HOT 7
- using custom matlab function HOT 1
- How to suppress the warning messages at the beginning of the MATLAB.jl processing? HOT 5
- libmx error when building HOT 7
- UndefRefError in MAC OS Apple Silicon HOT 3
- Variable interpolation from Julia to Matlab: Treat adjoint vectors as row vectors
- Mac M1: MATLAB.MEngineError("invalid engine session...
- how to use mat by MATLAB.jl ?
- segfault with Matlab 2022a on Windows HOT 10
- MATLAB code does not run / fails silently HOT 5
- Restart Matlab Session after fatal error exit
- Fail to build the MATLAB due to the load error of libmx HOT 9
- Unable to compile on Apple M1 HOT 3
- ERROR: UndefVarError: JULIA_HOME not defined Stacktrace: [1] top-level scope @ none:1 HOT 2
- Better anticipate Matlabs behavior regarding integer vs float values?
- Weird issue when also using Juliaup HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matlab.jl.