I have a bash script and I want to execute it from Matlab 2014b in Ubuntu 14.04. When I launch it from terminal (that I start from os) everything is ok. I try to launch it from Matlab like this
!./script.sh
It executes but cannot open image files that have to be loaded.
More than that if I launch terminal window from Matlab
!./gnome-terminal
and use it to launch the script I got the same 'file not found' problem. Text files are accessed with no problem. Path to the images are global. To load images opencv library is used. My guess is that for some reason opencv works different from Matlab, but I don't know what to do.
I spend a lot of time to figure out the problem, but still cannot resolve it. I will appreciate any advise or help.
LD_LIBRARY_PATH of Matlab shell differs from one of teminal shell. Following command in Matlab:
setenv('LD_LIBRARY_PATH', <content of LD_LIBRARY_PATH from terminal>)
solves the problem.
Content of LD_LIBRARY_PATH from terminal is printed by
echo $LD_LIBRARY_PATH
Related
I'm trying to automate mac terminal calls in MATLAB. In my specific use case I used brew to install cmake but in MATLAB cmake isn't recognized [~,result] = system('cmake ..'); returns zsh:1: command not found: cmake
Using the following I am pretty sure I could update the path so that cmake is recognized.
(Mac,Matlab,bash) Changing the PATH of bash in Matlab for system commands
However, I was wondering if there was a generic way of mimicking the path that the terminal is seeing.
In particular when I run env in the terminal and in MATLAB using [~,result] = system('env'); the path variables are different and I'm wondering why that is and how to ensure they align.
When you start MATLAB from its icon on macOS, you never ran the login shell startup files, so most of your configuration is not loaded. That is, anything configured in ~/.zprofile, ~/.zshrc, etc. is not seen by MATLAB. Unlike other Unixes, macOS doesn’t start a login shell when you log on. See here for the differences between a login shell and a non-login shell.
One way around this is to launch MATLAB from a terminal window. Another way is to manually load the zsh configuration before running your shell command.
A cleaner solution is to avoid ~/.zprofile (loaded for login shells) and ~/.zshrc (loaded for interactive shells), and instead put your configuration in ~/.zshenv (loaded for all shells, including the one started by MATLAB for system() or !).
In particular, Homebrew adds a line
eval "$(/opt/homebrew/bin/brew shellenv)"
to your ~/.zprofile file. Moving this line to ~/.zshenv and restarting MATLAB should add the Homebrew configuration to shells started from within MATLAB.
As the tile,I have a shell script needs to run every time I have to open a terminal and type "./ xxx.sh" .it is annoying when it gets too frequent now how do I execute by double clicking like the way you do it in windows?
I know there is an option just for that in Ubuntu but I can't see that here in CentOS.
I did a little bit of digging up and found these two links. Let me know if they were helpful
https://askubuntu.com/questions/286621/how-do-i-run-executable-scripts-in-nautilus
https://unix.stackexchange.com/questions/189777/how-to-launch-shell-script-with-double-click-in-centos-7
The first link is an askUbuntu link I know. But gnome uses nautilus as the file explorer program.
In my arch linux installation where I am running a cinnamon desktop environment, I just had to add a shebang (#!/usr/bin/bash) at the head of the file and use chmod to make the file an executable and I could run the script from by double clicking on it. I hope you have already tried this?
For the record this is how I do it:
In terminal
[youname#localhost ~]$ gedit ~/Desktop/YourApplication.desktop
In the file
[Desktop Entry]
Name=My Application
Comment=My Application run script
Exec=/AddressOfyourScript/yourscript.sh
Icon=/AddressOfyourIcon/youricon.png
Terminal=true
Type=Application
save and done.Apparently CentOS should give a GUI for this function.
I am having difficulties executing Matlab code in the Terminal using the matlab.tmbundle for TextMate... Spawning Matlab works fine as well as running code directly from the terminal but it seems that the code is getting lost when I attempt to run anything from TextMate.
When I "Execute in MATLAB", the running Matlab instance simply returns a new line (ie: >> in the Terminal). I assume there is an issue in the above command. Is it possible I don't have access to $TM_FILE_PATH?
I've looked everywhere for a solution but can't seem to find one. Thanks!
I have created a program (GUI) on MATLAB 7.6 (2010a) and compiled it using depoytool. however, when I try to run the program, it complains about a missig library file (libmwmclmcrrt.so.7.6). I have installed MCR, and I am trying to point to it by typing the filename followed by the path to the MCR, but nothing is working.
Suggestions?
On linux, MATLAB creates the startup script called run_progname.sh. You should run this script, and not your compiled program directly. Assuming you are in the directory where the program progname is compiled, execute
./run_progname.sh <deployedMCRroot> args
In windows, a .fig created by MATLAB can be easily opened. I am wondering if there is a way in ubuntu that allows you to open a .fig file through MATLAB. I guess i can open matlab then open there figures. But there shall be better ways.
Looks like only Matlab opens it, a Google search reveals that although *.figextension is usually associated with Xfig and related software but the Matlab's figformat seems to be a different, proprietary implementation.
Ubuntu Linux File Associations and this post on askubuntu might help on catching up with windows.
EDIT:
From within MATLAB use the menu 'FILE'->'Open', or the command line open figname.fig.
I know that this thread might be old, but there might be some people that still need this... :) So:
The idea to solve this is to assign a custom command to the file type "*.fig", which is: matlab -desktop -r "open(%f)", assuming that MATLAB is in your binaries.
If not then just make a symbolic link to it, like: sudo ln -s /{MATLAB_BIN_LOCATION} /usr/bin/
Under Ubuntu, if you cannot add a custom command like this:
Right click the .fig - file --> "Open with Other Application" --> Use a custom command --> matlab -desktop -r "open(%f)"
one can use Ubuntu Tweak for that.