Non-windows way to invoke Matlab from Mathematica - matlab

This was asked before, but the solution doesn't seem to work on MacOS. Wolfram Library has a package for 7 year old Matlab version. Is there a solution that works on MacOS 10.6 and Matlab 7.9?
I want to call CVX from Mathematica

You could use RunThrough["command",expr], this runs the external command command, and feeds expr (a Mathematica expression) as input to command
An example of a suitable command would be "matlab -r \"matlab expr\"", you could place your CVX specific code in the "matlab expr" string.

Update: Right now, probably MATLink is the best way to do this. It works on Windows/Linux/Mac.
Disclosure: I'm one of MATLink's authors.
Have you tried using the newer mEngine instead? I can only try it on Windows, but after looking at the sources, I believe it might work on other platforms too.
Hopefully you only need to modify main.c, actually just copy and paste the main function from one of the MathLink examples (e.g. addtwo), as mEngine's main.c has the non-Windows-specific part removed. Then compile the package as a MathLink program.

Related

How to make an executable file on matlab and run on raspberry pi 3B [duplicate]

I was wondering if there is a way to create a '.exe' file from ' .m' file in MATLAB, such that it can be run in machine which does not have MATLAB (like it can be done in C, C++).
I know writing a MATLAB function is one way, but I am not sure if it can run in machine without MATLAB.
Also I would like to hide my code and just create a script which can be run by a user using his own data files.
The Matlab Compiler is the standard way to do this. mcc is the command. The Matlab Runtime is required to run the programs; I'm not sure if it can be directly integrated with the executable or not.
If you have MATLAB Compiler installed, there's a GUI option for compiling. Try entering
deploytool
in the command line. Mathworks does a pretty good job documenting how to use it in this video tutorial: http://www.mathworks.com/products/demos/compiler/deploytool/index.html
Also, if you want to include user input such as choosing a file or directory, look into
uigetfile % or uigetdir if you need every file in a directory
for use in conjunction with
guide
Try:
mcc -m yourfile
Also see help mcc
If your code is more of a data analysis routine (vs. visualization / GUI), try GNU Octave. It's free and many of its functions are compatible with MATLAB. (Not 100% but maybe 99.5%.)
mcc -?
explains that the syntax to make *.exe (Standalone Application) with *.m is:
mcc -m <matlabFile.m>
For example:
mcc -m file.m
will create file.exe in the curent directory.
It used to be possible to compile Matlab to C with older versions of Matlab. Check out other tools that Matlab comes with.
Newest Matlab code can be exported as a Java's jar or a .Net Dll, etc. You can then write an executable against that library - it will be obfuscated by the way. The users will have to install a freely available Matlab Runtime.
Like others mentioned, mcc / mcc.exe is what you want to convert matlab code to C code.
The "StandAlone" method to compile .m file (or files) requires a set of Matlab published library (.dll) files on a target (non-Matlab) platform to allow execution of the compiler generated .exe.
Check MATLAB main site for their compiler products and their limitations.
I developed a non-matlab software for direct compilation of m-files (TMC Compiler). This is an open-source converter of m-files projects to C. The compiler produces the C code that may be linked with provided open-source run-time library to produce a stand-alone application. The library implements a set of build-in functions; the linear-algebra operations use LAPACK code. It is possible to expand the set of the build-in functions by custom implementation as described in the documentation.

Compile Swift on Windows from Silver Command Line?

I've been learning Swift for a little bit now, and I really want to use it. However, compiling Swift on Windows is quite a chore. I can do it from Visual Studio 2015 easily, but VS2015 support is very poor, and incredibly hard to work with; I would prefer to use Atom and the command line. I use RemObject's Silver to compile to .NET, but I can never get the command line to work.
When I use the Elements.exe at C:\Program Files (x86)\RemObjects Software\Elements\Bin, passing the filename as a parameter, it tells me that print is undefined.
Does anyone know how to use Silver's command line to compiler Swift?
Have you tried referencing the online documentation?
calling elements needs some libraries to import:
elements --mode=ECHOES --reference=Swift myfile.swift
I recommend using MSBuild, rather than Elements.exe, to build Elements projects from the command line. It's more complete and supports more advanced build tasks needed for some project types.
That said, --mode and --reference should definitely work. Can you post a complete command line and output?
You will need --reference=Swift in order for print() & co to be known, and --reference System.Core to use LINQ.

Mex or Compile (mcc) Matlab function that uses toolkits

Environment:
Matlab R2012a (I have access to others if necessary)
All Toolboxes/Compiler installed
Ubuntu 12.04 64bit and/or Windows 7 64bit
I am working with the source for a software package written in Matlab (unfortunately its proprietary so no code examples...sorry), and one function briefly uses the Control System Toolbox and the Signal Processing Toolbox.
I have no problem running the code on my personal computer because I have every toolbox installed, however I would like to compile (mex or mcc) JUST the function using those two toolboxes. The goal, of course, is to run the software on a machine without those toolboxes, while leaving the remaining code open to change.
According to matlab, they have no problem with you compiling code that uses almost any toolbox. Here is the list of toolboxes that support mcc compilation:
http://www.mathworks.com/products/compiler/supported/compiler_support.html
The problem arises in that mcc no longer allows compiling with the -x option to create a mex-ed version of the function, so I'm forced to create a C executable (maybe? hopefully not). This particular function takes large matrices as parameters (impractical to write as a command line argument) and returns a structure of cell arrays.
The only way around this (as I see it now) would be to write the arguments (large matrices) to the hard drive in a binary .mat file , have the compiled C binary read in the arguments, run the algorithm, and finally save the return values in another .mat for the parent thread to load back into memory.
This seems totally impractical. I would greatly appreciate alternative suggestions. Please let me know if anything here in unclear. Thanks in advance!
[Edit 1] The codegen package does not support tf.m. It seems like this should be possible (and used to be possible with the mex -x option), but I'm at a loss. Any suggestions would be greatly appreciated!
I think the reason -x is not supported anymore is the fact that Matlab now has a product called "coder", which converts .m files to .c files and can also create .mex files from "suitable" .m files using the option -args to specify the input arguments: http://www.mathworks.com/videos/generating-c-code-from-matlab-code-68964.html

octave install matlab package

Recently I choose to use Octave instead of Matlab in Ubuntu12.04 due to the fact that it is open sourced. One problem I encounter is that when I try to install some additional package of matlab, it always fails.
For example, I want to install the randomforest matlab package (http://code.google.com/p/randomforest-matlab/), it needs to run command "make" to compile the c++ code etc. But first it tells me there's no mex command. To solve this, I modified the Makefile by replacing "mex" with "mkotfile --mex", after the second run, there are errors associated with the source code of the package.
This happens for multiple times, like I fails to install the libsvm in Octave.
Does anyone know how to solve this? Or I have to return to use Matlab.
Octave and Matlab are different enough to cause situations like these. Things developed for Matlab will usually not work as-is on Octave, especially external packages (i.e., not developed by the Mathworks).
You'll just have to persist -- re-write some parts of the code, install additional libraries here and there, etc. to get it to work.
It's always possible, but whether it's practical, that's for you to decide.

Which values are allowed for environment variable MAKE_MODE when using GNU make?

I usually have an environment setting for MAKE_MODE (Windows XP, using GNU make, both under Cygwin and native)
set MAKE_MODE=UNIX
I now found differences between my build server (which has no MAKE_MODE defined) and a local build. This may be something completely different, but it got me wondering what other values I could specify for MAKE_MODE.
I think I know that MAKE_MODE=UNIX is suppose to tell GNU make to use /bin/sh - if it finds it - , but I quickly checked the GNU make manual and couldn't find a description. A google search only told me what I already know, but doesn't give a valid alternative.
Is the only alternative to not define the variable? Does it have influence at all when using CMD.exe and a native version of GNU make?
EDIT: So far I have found references for the values 'unix', 'win32', 'null' and undefined, but no explanations, and no specifications. But a look at the source code for GNU make 3.82 shows not a single occurrence of the string "MAKE_MODE", so GNUmake itself apparently doesn't change its behavior when this environment variable is set or not.
EDIT2: I checked the source code for GNU make for MinGW, and again found nothing. Maybe it's CygWin specific?
EDIT3: I found a reference that it might be property of an old version of GNU make, so I checked version 3.75. No luck, the string MAKE_MODE does not appear in the source code at all. The next step really must be the Cygwin version of GNU make. I know from 10 years ago that the Cygwin port in those days was not integrated in the regular source tree.
I found an ancient mailing list entry on the Cygwin site, explaining the basic operational effect of MAKE_MODE. This definitely indicates that the variable has to do with the Cygwin implementation of GNU make.
I'll dig around in the source code, and add to this answer when I find more details.
UPDATE: In a more recent post by maintainer Christopher Faylor I found the following update for GNU make version 3.81:
Note that the --win32 command line option and "MAKE_MODE" environment
variable are no longer supported in Cygwin's make. If you need to use a
Makefile which contains MS-DOS path names, then please use a MinGW
version of make.
I've not really found the values allowed for MAKE_MODE, but it's not any more necessary or supported in most recent versions of GNU make for Cygwin, and it was used for supporting DOS filenames in Cygwin's make.
And if you really want to know the set of allowed values, look in the source for Cygwin's make version before 3.81-1. I guess the only useful value was unix, all others will have meant the same.
Case closed? There's still not many views here...