Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Matlab and Octave support #36

Open
gpoore opened this issue Feb 15, 2014 · 5 comments
Open

Add Matlab and Octave support #36

gpoore opened this issue Feb 15, 2014 · 5 comments

Comments

@gpoore
Copy link
Owner

gpoore commented Feb 15, 2014

Starting development.

  • This will likely need a rewrite of the stderr parser (which is needed anyway).
  • Getting a full utilities class working may be more difficult than for other languages, given the restrictions of the languages (Matlab has classdef, which looks good, but Octave is still working with the older @classes).

Commit 29eef86 adds primitive Octave support.

Note on development

The template system for adding language support is only sparsely documented at present. This is because the system is subject to change as additional languages are added in the future. The system will stabilize at some point, but several different types of languages must be added first so that we can be sure that the system has a relatively complete feature set.

Note for Octave development

Initial solution for running scripts was a template command of the form

'{octave} -q --eval "cd \'{Outputdir}\'; more off; {file}"'

But that isn't ideal because it changes the working directory, which would then have to be changed again in {file} to whatever the user wants. A better option is something like

'{octave} -q "{File}.m"'

where the new {File} field is the name of the file to be executed, including the full path.

gpoore added a commit that referenced this issue Feb 17, 2014
@gpoore
Copy link
Owner Author

gpoore commented Feb 17, 2014

Some discussion on Octave support got into another issue (see this and this).

After looking into Octave's @classes, I've decided not to implement a utilities class. Given how Octave classes work, something like

add_dependencies(octavetex, 'dep1', 'dep2', ... )

would be needed. But what I would really want, to parallel other languages, is something like

octavetex.add_dependencies('dep1', 'dep2', ... )

This is more object-oriented, and also avoids namespace collision issues.

The current solution uses functions instead of methods. So octavetex_add_dependencies() instead of octavetex.dependencies(), etc. All data is stored in an octavetex struct. So octavetex.context, etc., works. It's only the "methods" that must be accessed as functions. One significant advantage of this approach is that all functions may be defined in the Octave template. For a class, there would have to be a directory and one or more .m files, which would need to be added to Octave's search path.

Since Octave doesn't have associative arrays, octavetex.context is a struct. This means that the key-value pairs that can be passed (and then accessed without getfield()) will be somewhat limited. But there isn't an alternative.

Matlab has classdef and containers.Map, so it should be a nicer case to deal with.

@gpoore
Copy link
Owner Author

gpoore commented Jul 3, 2014

Octave support is essentially complete with 056c84c.

@fcdimitr
Copy link

fcdimitr commented Feb 1, 2023

Any progress on adding support for MATLAB? Octave is helpful, but MATLAB has a large set of additional toolboxes and functions not available in Octave.

Thank you very much for this excellent package!

@gpoore
Copy link
Owner Author

gpoore commented Feb 1, 2023

I haven't used MATLAB in a long time. If you want to try to get MATLAB working, using the Octave support as a template, you could look at pythontex_engines.py.

If you can work with Markdown instead, you might be able to use one of my other projects, Codebraid. It appears that a MATLAB Jupyter kernel has just been released (non-Windows only). Codebraid supports arbitrary Jupyter kernels. Codebraid currently only supports code execution in Markdown, but I'm exploring various ways to use it with LaTeX.

@fcdimitr
Copy link

fcdimitr commented Feb 1, 2023

Thanks! I will take a look at how to extend this package to include MATLAB and Codebraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants