Giter Site home page Giter Site logo

Comments (19)

musm avatar musm commented on August 20, 2024

where does it save if you run the file from matlab alone?

from matlab.jl.

musm avatar musm commented on August 20, 2024

check the directory

julia> mat"pwd"
"C:\\Program Files\\MATLAB\\R2016b"

from matlab.jl.

musm avatar musm commented on August 20, 2024

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.

dsweber2 avatar dsweber2 commented on August 20, 2024

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.

dsweber2 avatar dsweber2 commented on August 20, 2024

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.

musm avatar musm commented on August 20, 2024

Strange, I can't reproduce. Are you sure you can't reproduce those errors from matlab alone?

from matlab.jl.

dsweber2 avatar dsweber2 commented on August 20, 2024

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.

musm avatar musm commented on August 20, 2024

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.

musm avatar musm commented on August 20, 2024

which version of matlab and which julia version and are you on master MATLAB.jl ?

from matlab.jl.

dsweber2 avatar dsweber2 commented on August 20, 2024

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.

musm avatar musm commented on August 20, 2024

cc @simonster

from matlab.jl.

musm avatar musm commented on August 20, 2024

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.

musm avatar musm commented on August 20, 2024

@dsweber2 what happens when you try julia> eval_string("test($x)")

from matlab.jl.

musm avatar musm commented on August 20, 2024

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.

dsweber2 avatar dsweber2 commented on August 20, 2024

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.

simonster avatar simonster commented on August 20, 2024

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.

musm avatar musm commented on August 20, 2024

@simonster currently it spits an ERROR: ArgumentError: Unsupported kind of variable.
Perhaps a warning is more appropriate and to return nothing?

from matlab.jl.

dsweber2 avatar dsweber2 commented on August 20, 2024

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.

RoyiAvital avatar RoyiAvital commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.