gnu-octave / symbolic

A Symbolic Package for Octave using SymPy
https://octave.sourceforge.io/symbolic/
GNU General Public License v3.0
154 stars 36 forks source link

Using octsympy in MATLAB #1256

Open jabierros opened 1 year ago

jabierros commented 1 year ago

Hi all!.

Let me know if it is OK to post here. I've not been able to find a different place.

I'm a bit confused with the info in the README.md file about installing on MATLAB

I have some questions:

  1. I don't know where to get octsympy-matlab-2.7.0.tar.gz, I've been able to find a symbolic package in Sourceforge symbolic-3.1.1.tar.gz but for the README.md this seems to be the standard Octave package and that therefore some re-formatting may be needed to conform to MATLAB comment conventions.

  2. I don't know if I need to install python, I suppose that yes, I'm in Ubuntu, so I assume that I can follow the octsympy Octave installation [instructions }(Matlab comment conventions).

  3. I assume then that I can somehow run MATLAB from a venv, in which I have python and sympy. And then be able to fine grain choose the required versions.

  4. By the way, which Python version are you using?.

Thanks!!!

Javier

cbm755 commented 1 year ago

Totally fine to post here. The Matlab package is not built by default any more since 3.0.0.

  1. Matlab packages are generally found under "assets" under "releases" but the older versions may not work with recent Python and Sympy.

  2. Yes

  3. Probably? But I'm not an expert on venv.

  4. I'm not sure we document the earliest supported Python. Its probably 3.6 or 3.7 (whatever SymPy has as the minimum for example).

cbm755 commented 1 year ago

You can run make matlab_pkg (update: fixed command) to build the package from the latest sources: I haven't tested in Matlab for a while but feel free to file issues for any bugs you find (#-style comments and " strings tend to creep in over time, maybe other incompatibilities, since we only test on Octave).

alexvong243f commented 1 year ago

As a side note, this page https://github.com/cbm755/octsympy/releases contains all released tarballs and zip files, including old ones.

You may want to try the v2.9.0 octsympy package for matlab to see if it works out of the box.

jabierros commented 1 year ago

Hi!.

Well, I'm trying. I have to use the "Source code" (v3.1.1, tar.gz). Symbolic-3.1.1-tar.gz Makefile does not seem to have a matlab target. The MATLAB targets available are

$ make matlab_ matlab_pkg matlab_test

$ make matlab_pkg ....

This seems to work. But

(oct_sympy_matlab_env) $ make matlab_test fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). cd "tmp/octsympy-matlab-3.1.1"; matlab -nodesktop -nosplash -r "; octsympy_tests_matlab" /bin/bash: matlab: command not found make: *** [Makefile:172: matlab_test] Error 127

but doing

(oct_sympy_matlab_env) $ cd "tmp/octsympy-matlab-3.1.1"; matlab -nodesktop -nosplash -r "; octsympy_tests_matlab"

                                                    < M A T L A B (R) >
                                          Copyright 1984-2023 The

MathWorks, Inc. R2023a (9.14.0.2206163) 64-bit (glnxa64) February 22, 2023

Warning: X does not support locale en_US.UTF-8

To get started, type doc. For product information, visit www.mathworks.com.

Running test(s) in: tests__assume.m ssssss.Symbolic pkg v3.1.1: using slower system() communications with SymPy. Warning: this will be SLOW. Every round-trip involves executing a new python process and many operations involve several round-trips. Error: File: /home/*****/Sync/Programming_Tricks/octsympy-3.1.1/tmp/octsympy-matlab-3.1.1/private/assert_have_python_and_sympy.m Line: 82 Column: 5 Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.

Error in python_ipc_system (line 86) assert_have_python_and_sympy (pyexec)

Error in python_ipc_driver (line 68) [A, db] = python_ipc_system(what, cmd, false, varargin{:});

Error in pycall_sympy__ (line 142) [A, db] = python_ipc_driver('run', cmd, varargin{:});

Error in valid_sym_assumptions (line 38) List = pycall_sympy__ (cmd);

Error in assumptions (line 69) A = valid_sym_assumptions();

Error in syms (line 108) valid_asm = assumptions('possible');

Error in tests__assume (line 27) syms x

Error in octsympy_tests_matlab (line 41) eval(str)

proceeds somehow further away

Just for information.

Don't spend much time on this because right now I'm shopping around libraries and programming styles to base mine on.

So anyway many thanks.

Javier

On Sun, Jul 2, 2023 at 12:28 AM Colin B. Macdonald @.***> wrote:

You can run make matlab to build the package from the latest sources: I haven't tested in Matlab for a while but feel free to file issues for any bugs you find (#-style comments and " strings tend to creep in over time, maybe other incompatibilities, since we only test on Octave).

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/cbm755/octsympy/issues/1256*issuecomment-1616163331__;Iw!!D9dNQwwGXtA!T4Qofx6UuZHIusDPMAzBB124qmoxG8Z5EPg4FAFhsELJCNDZVXgZVMenuw06Fb0l4HcF1oaFFvTKTExcw7xjMnM$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ACXN6CSX4JJNLKDEVZKDJE3XOCP7TANCNFSM6AAAAAAZYJR3S4__;!!D9dNQwwGXtA!T4Qofx6UuZHIusDPMAzBB124qmoxG8Z5EPg4FAFhsELJCNDZVXgZVMenuw06Fb0l4HcF1oaFFvTKTExcq6sfWoE$ . You are receiving this because you authored the thread.Message ID: @.***>

cbm755 commented 1 year ago

I think I fixed that in the main branch. You can full latest code (not the latest release) or wait for the next release.

If you're not used to git, you might be able to get via the green "Code" butten then "Download ZIP" (but I've never tried this myself)... You might still have to make matlab_pkg to get a package that works in Matlab. Sorry its been a long time since I've tried it in properly Matlab.