{"id":19339360,"url":"https://github.com/juliamatlab/mexjulia","last_synced_at":"2025-04-23T02:30:39.597Z","repository":{"id":27979774,"uuid":"31473241","full_name":"juliamatlab/mexjulia","owner":"juliamatlab","description":"embedding Julia in the MATLAB process.","archived":false,"fork":false,"pushed_at":"2021-10-24T04:16:51.000Z","size":123,"stargazers_count":53,"open_issues_count":16,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-15T23:03:24.312Z","etag":null,"topics":["julia","matlab","mex"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliamatlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-28T19:13:26.000Z","updated_at":"2024-12-09T16:00:25.000Z","dependencies_parsed_at":"2022-08-26T11:20:42.151Z","dependency_job_id":null,"html_url":"https://github.com/juliamatlab/mexjulia","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2Fmexjulia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2Fmexjulia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2Fmexjulia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliamatlab%2Fmexjulia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliamatlab","download_url":"https://codeload.github.com/juliamatlab/mexjulia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357526,"owners_count":21417295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["julia","matlab","mex"],"created_at":"2024-11-10T03:21:27.474Z","updated_at":"2025-04-23T02:30:39.347Z","avatar_url":"https://github.com/juliamatlab.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"![mexjulia.icon](doc/logo.png)\n\n# `mexjulia`: embedding [Julia](http://julialang.org/) in the [MATLAB](http://www.mathworks.com/products/matlab/) process.\n\nNote: this project is effectively in hibernation as its author no longer has access to matlab.\n\n## Prerequisites\n\n`mexjulia` requires MATLAB (tested with R2016b) and Julia (\u003e=v.0.6-dev) along with a C++ compiler configured to work with MATLAB's `mex` command, the last is required for building the `mexjulia` MEX function. You can check that a compiler is properly configured by executing:\n\n```\n\u003e\u003e mex -setup C++\n```\n\nfrom the MATLAB command prompt.\n\n## Configuration\n\nStart MATLAB and navigate to the `mexjulia` directory. Once there, run:\n\n```\n\u003e\u003e jl.config\n```\n\nYou will be prompted to select a `julia` executable. The build process will:\n 1. use `julia` to determine build options,\n 1. build the `mexjulia` MEX function from source,\n 1. add the `mexjulia` directory to your MATLAB path.\n\nCall `jl.config` any time you want to build against a different version of Julia. You can\npass in the path to the desired Julia executable to build against if you don't want\nto be prompted to select one.\n\n## Quick start\n\nUse `jl.eval` to parse and evaluate MATLAB strings as Julia expressions:\n\n```\n\u003e\u003e jl.eval('2+2')\n\nans =\n\n  int64\n\n   4\n```\n\nYou can evaluate multiple expressions in a single call:\n\n```\n\u003e\u003e [s, c] = jl.eval('sin(pi/3)', 'cos(pi/3)')\n\ns =\n\n    0.8660\n\n\nc =\n\n    0.5000\n```\n\nJulia's `STDOUT` and `STDERR` are redirected to the MATLAB console:\n\n```\n\u003e\u003e jl.eval('println(\"Hello, world!\")');\nHello, world!\n\u003e\u003e jl.eval('warn(\"Oh, no!\")');\nWARNING: Oh, no!\n```\n\nOne can avoid the parentheses and string quotes using `jleval` (a simple wrapper around\n`jl.eval`) and MATLAB's command syntax:\n\n```\n\u003e\u003e jleval 1 + 1\n\nans =\n\n  int64\n\n   2\n\n\u003e\u003e jleval println(\"Hello, world!\")\nHello, world!\n```\n\nUse `jl.call` to call a Julia function specified by its name as a string:\n\n```\n\u003e\u003e jl.call('factorial', 10)\n\nans =\n\n     3628800\n```\n\n`jl.call` marshals MATLAB data to/from Julia making certain default choices for doing so.\n\nLoad new Julia code by calling `jl.include`:\n\n```\n\u003e\u003e jl.include('my_own_julia_code.jl')\n```\n\nExercise more control over how data is marshaled between MATLAB and Julia by defining\na Julia function with a \"MEX-like\" signature and invoking it with `jl.mex`:\n\n```\n\u003e\u003e jleval double_it(args::Vector{MxArray}) = [2*jvalue(arg) for arg in args]\n\u003e\u003e a = rand(5,5)\n\na =\n\n    0.6443    0.9390    0.2077    0.1948    0.3111\n    0.3786    0.8759    0.3012    0.2259    0.9234\n    0.8116    0.5502    0.4709    0.1707    0.4302\n    0.5328    0.6225    0.2305    0.2277    0.1848\n    0.3507    0.5870    0.8443    0.4357    0.9049\n\n\u003e\u003e jl.mex(1, 'double_it', a)\n\nans =\n\n    1.2886    1.8780    0.4155    0.3895    0.6222\n    0.7572    1.7519    0.6025    0.4518    1.8468\n    1.6232    1.1003    0.9418    0.3414    0.8604\n    1.0657    1.2450    0.4610    0.4553    0.3696\n    0.7015    1.1741    1.6886    0.8714    1.8098\n```\n\nThe first argument to `jl.mex` is the number of return values to expect. The second is the name of the function to be invoked. All remaining arguments are treated as function arguments. `jl.mex` expects the functions on which it is invoked to accept a single argument of type `Vector{MxArray}` and to return an iterable collection of values on which `mxarray` may be successfully invoked (_e.g._, a value of type `Vector{MxArray}`).\n\nSee [`lmdif_test.m`](examples/lmdif_test.m), [`lm.m`](examples/lmdif.m), and [`lmdif.jl`](examples/lmdif.jl) for a more complex example that exposes [`Optim.jl`](https://github.com/JuliaOpt/Optim.jl)'s Levenberg-Marquardt solver to MATLAB. It presents an example of a MATLAB function handle being passed to Julia and used as a\ncallback. (The default marshaling wraps matlab function handles in an anonymous function.)\n\n## Known Issues\n\n - On Windows, if a julia is on the path it must be the one against which `mexjulia` is built.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliamatlab%2Fmexjulia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliamatlab%2Fmexjulia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliamatlab%2Fmexjulia/lists"}