Run older version of MATLAB in batch file - matlab

There are two versions of MATLABs (2007a and 2019a) installed on my computer. The 2019a is installed after 2007a so if you use the following code in batch file:
start matlab -r "xxx.m"
The system will call 2019a instead of 2007a.
I searched online and found that most of people say you can call older version by:
start "C:\Program Files (x86)\MATLAB\2007a\bin\win32\MATLAB.exe" -r "xxx.m"
I tried but it give me this error:
if the batch file doesn't include any command ("-r" etc.), it works just fine. MATLAB can be opened without problems.
What's the mistake I made? How could I call older version and have it run some functions?
My OS: Win7

Thanks for all of guys who commented under my question. Turned out there are two ways to do this.
As one of comment said, you just need a pair of "" after start:
start "" "C:\path\MATLAB.exe" -r "xxx.m"
You actually don't need "start", just use directory is fine:
"C:\path\MATLAB.exe" -r "xxx.m"
Both ways solve the problem. A good lesson to learn for starters.

I know this post is old. But I was searching for a solution and found one by myself. The best way is to change the order of the windows environment variables. just put the older version over the newer one and you can use the old script.

Related

Issue with using the system-command

when I use in a terminal session
curl -help
I get the help list. When I use in MATLAB
system ('curl -help')
I get the error:
System Lookup error, curl : undefined symbol:curl_url_cleanup. Linux is Fedora based Solus 4.0
In my understanding the system command should work like this. How can I get the help file?
MATLAB modifies the LD_LIBRARY_PATH environment variable, so that its own libraries can be found. However, MATLAB comes with tons of external libraries, and usually these are older versions.
So it happens at times that a command executed through system links to a version of a library that comes with MATLAB, rather than the one that comes with the OS.
The solution is to execute the command in a "clean environment", such as the one provided by env -i:
system('env -i curl -help')

libhdf5.so.103: cannot open shared object file

I have met a problem with hdf5 libraries on eclipse CDT. When running a test C++ program, I got prompt information as below:
/home/lsl/Documents/CODE/eclipse-workspace/ReadWriteHDF5/Debug/ReadWriteHDF5:
error while loading shared libraries: libhdf5.so.103: cannot open
shared object file: No such file or directory.
libhdf5.so is confirmed to exist in /usr/local/lib/hdf5-1.10.4/lib and /usr/local/lib/hdf5-1.10.4/lib is within LD_LIBRARY_PATH. Do you have any indications?
Thanks very much!
It looks like Linux is your main operating system. See what happens when you type
sudo apt install libhdf5-dev
since it might supplant the package you're looking for. It worked for me.
I come across similar issue while compiling C++ code that uses Armadillo. Since I have anaconda installed, I find the libhdf5.so.103 file located at ~/anaconda3/lib. After I add the path to LD_LIBRARY_PATH, the error disappears.
I came across exactly the same problem today (perhaps the only difference is that it complaint libhdf5.so.200 was missing). What I eventually found out is that the system (Ubuntu 20.04) already shipped with libhdf5-dev at version 1.10.4, and this conflicted somehow with my installed version 1.12.2. My build command line is as below:
clang++ <...> -L/my/custom/path/to/hdf5-1.12.2/hdf5/lib <...>
Since the system hdf5 is in standard location, the linker finds simultaneously two versions, causing problem.
My solution is:
sudo apt purge libhdf5-dev
Hope it helps.

How to use mxnet on windows with matlab bindings

Can anyone tell me if it is possible to use mxnet with matlab on windows? Using the windows packaged releases from https://github.com/dmlc/mxnet/releases, there is no "matlab" directory, which I can see is present in the newer versions, which do not have windows packages.
is there a way to get the best of both worlds?
Yes, it works, even thought I doubt it has been extensively tested. Their Matlab wrapping assumes the library lies in the lib directory, which is inconsistent with their python wrapping that assumes it lies in the build directory. So you will either have to copy libraries or change paths in callmxnet.m. Also, the demo needs data that is currently fetched by a bash script -- not very Windows friendly but it runs flawlessly with MSYS2.
IMHO the Matlab demo is currently more a proof-of-concept than a real Matlab wrapper. It is nowhere near the python bindings.
The matlab directory is directly on the repo not as a release:
https://github.com/dmlc/mxnet/tree/master/matlab
Maybe you can compile it for windows using cygwin or msys2, On the documentation it say that it was tested for matlab version:
Matlab binding has been tested with the following version:
R2016b (9.1.0.441655) 64-bit (glnxa64)
Which is a linux version; I think that it should be posible to reproduce the instructions in the readme to make it work woth cygwin or msys2 with windows

Eclipse IDE: How to add this configuration during running?

For running of one of my C++ programs, using terminal(Ubuntu) I use
Note: I'm trying to Embed Python in C++. Hence, PYTHONPATH in C++.
Refer to Python/C API for more details.
$ PYTHONPATH=. ./prog_name
Sorry, I didn't know how to ask this question on Google. I want to do the same running with Eclipse. I don't know where to specify PYTHONPATH=. during running from Eclipse. How to produce the equivalent of this? I tried putting in argument list, but obviously it didn't work. Thanks!
PS. Don't downvote just because you don't understand that python scripts can be called through C++ .. Lol
Hi to all those facing the same problem, i found the solution!
setenv() is a function defined in which sets the environment variable. Just have to run it!
setenv("PYTHONPATH",".",1);
for more info on setenv:
$ man setenv
All the best :)

How to completely reset MATLAB?

I want to be able to run MATLAB from a perfectly clean slate: no history, no snapshots, no customizations, nothing. Better yet, I'd like to be able to start a MATLAB session in the state that one would start at if one had just installed MATLAB. Is this possible?
(Of course, I'm looking for a solution that does not require me to obliterate every trace of MATLAB from my hard disk [which probably cannot be done without reformatting the drive], and then re-install in it a fresh copy of MATLAB.)
FWIW, I'm running 7.11.0 R2010b. (The shockingly rare/arcane solutions I've found online so far don't work with this version.)
Thanks!
Best bet might be to open the prefdir and delete settings (untested by me):
prefdir - Folder containing preferences, history, and layout files
Syntax:
prefdir
folder = prefdir
folder = prefdir(1)
From here: http://www.mathworks.com/help/techdoc/ref/prefdir.html
Reset to a new instance (like you just opened a new session of MATLAB):
!matlab &
exit
Source: http://www.mathworks.com/matlabcentral/answers/1093
Create a virtual machine in Virtualbox, VirtualPC or similar. Install OS + Matlab on it. Snapshot or clone the system at that point. Now, whenever you want to run a "fresh matlab", startup the VM from the snapshot.
One other approach is to use a newly-concocted directory as your $HOME for the session. Something like this (on Linux, using bash syntax)
$ mkdir /tmp/dummyHome
$ HOME=/tmp/dummyHome matlab &