open MATLAB figure in ubuntu - matlab

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.

Related

How do I run MATLAB (.m) files in VSCode?

I am not able to figure out how to run MATLAB (.m) code in VSCode.
I have installed the MATLAB Extension for VSCode and added the path for the mlint file for MATLAB as stated in the extension.
"matlab.mlintpath"
VSCode identifies the file as a MATLAB file. However, the code won't run.
How can I run MATLAB code from within VSCode?
There is a way, this VSCode extension suggests that you can use it to run MATLAB code from within VSCode without having to open the MATLAB GUI. It does not invalidate the below though; you need to have a working, licensed MATLAB installation, which will be called in the background. Without a working, licensed MATLAB installation you cannot run MATLAB code.
As MATLAB is proprietary, there are only two ways to run MATLAB code: by running the code from the MATLAB IDE (with a valid license of course), or by compiling it to an executable file with the MATLAB compiler.
You might be able to get other IDEs to have syntax highlighting and typing-hints like MATLAB's own IDE through importing its mlint functionality, like you did, but that won't execute the code.
Thus no, you cannot execute MATLAB code directly within VSCode, you can only covertly call the MATLAB engine from inside VSCode.
A possible workaround would be to export your MATLAB code to C/C++ using the MATLAB Coder. You can then run the C/C++ code from within VSCode.
TL;DR:
I wrote Matlab Terminal Extension for VS Code on Linux. It can run matlab files and spawn a matlab-Terminal. You can find the repo here.
MatTer for VS Code
I recently wanted to used a matlab terminal in vscode. There even is an extension for this. But while using the extension I faced some flaws. Also the repository does not seem to be active anymore and the owner doesn't react to issues and similar.
So I decided to write my own first extension MatTer for VS Code and published it to the VS marketplace. It's in early Development, but it can already spawn a matlab-Terminal and run matlab files.
The repo is hosted on Github, see here: https://github.com/mauzigoe/matter-for-vscode
To install it via vscode just search for matter-for-vscode in Extension.
Critics and Feedback is welcomed, esp. since I'm new to this.
"#Liam the long discourse is necessary, because having the extension without a valid MATLAB license+installation won't work.T"
...because at some point you need at least ONE working matlab install just to develop the m-file :)
I suspect that you're right, and it comes down to a choice between embedding "foreign" code into an m-file, or making calls to the matlab engine from within a foreign IDE. They do have a free RTE but you still need some form of Matlab IDE to write in plus the Matlab Compiler toolbox to build the project out for the RTE.
The work-around is to use OS tools to remove Matlab and other proprietary tools from the loop entirely. That is why if you're going to be forced to pay $5k for a proprietary tool, it has to be justified in other ways than "it can get the job done".
VS Code extensions have the same problem as any other extension: if you look at the repository and see what is required to install and run the extension? You'll probably never install an extension again. It's about as wise as blithely downloading and installing any code from the Internet: it's no better than the source. I would wait until you figure-out how to call getOpen() etc within VS Code without downloading some random extension from some random source especially one that hasn't been updated in the past 2 years. Or at least use VS2019 Community:
https://www.mathworks.com/matlabcentral/answers/100603-how-can-i-compile-a-matlab-engine-application-using-microsoft-visual-studio-9-0-or-10-0
you could use the "Matlab Interactive Terminal" Extention, the link is below.
To use it, you need to follow the instruction to install a "MATLAB Engine API for Python" and you are good to go (and you need a working Matlab).
after installing the extension, you could open the Matlab terminal in the command window (by pressing Ctrl+Shift+P and input "Open a Matlab Terminal"), and you could get the same Matlab terminal as in the real Matlab IDE, and now you could run .m code in Vscode.
You can use the Code Runner extension and put this line in your settings.json:
"code-runner.executorMapByFileExtension": {
".m": "cd $dir && matlab -batch \"$fileNameWithoutExt\""
}
You would probably also want to install the MATLAB extension.

Matlab path tool refuses to save pathdef.m

I've just installed matlab 2019a and keep getting the same error where Matlab says it cannot save the pathdef.m file because it's write protected. When i choose to save to another location, and press close it keeps coming with the same question to store the pathdef.m elsewhere...? Is this a bug in 2019a?
It was a whole other issue... I tried to add a toolbox with too many items... that caused pathdef.m to freeze... now it's all working fine!!
I had a similar issue in Ubuntu 18.04 but I managed to fix it. This is what I did:
Find prefdir location by typing prefdir into MATLAB command window. In my case:
/home/myusername/.matlab/R2019a
So I did the following in Ubuntu terminal:
sudo chown -R myusername /home/myusername/.matlab/R2019a

Can somebody help me make Visual Studio Code with Julia ?

I am studying economics so I have not much experience in programming. I really would like to make Julia work on Visual Studio Code but I've been unsuccessful.
So I downloaded the Julia extension but I don't know how to define the settings. Do I need to create a launch.json file or any other file to make it work?
I think that somebody asked a similar question previously at "How to setup Julia in VS code?"
but the answer didn't really help me.
Thank you all for your help.
First you need to install Julia on your Mac by downloading the julia dmg file from here. This puts an application in the Applications folder.
There are several ways to set things up so julia will run from command line. I used the following:
ln -fs "/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia" /usr/local/bin/julia
This should work if the name of your application, that you just installed, is julia-0.6.app
After running the above command, you should be able to type Julia on the command line and have it to start.
You can now create a Julia script and place it in the directory you're running from. I created a file named julia_test001.jl It contained the following:
for i in 1:5
print(i, ", ")
end
This is a very short Julia script I wrote for testing.
Now start VScode and install the Julia language support extension. After that has loaded, open the file Julia_test001.jl. Once this file is opened, click the triangle in the upper right corner or open the command palette and select the option: run code. The julia_test001.jl should run and print the result 1,2,3,4,5.

Execution of bash script differs when runned from Matlab and Terminal

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

How can I create a make file using Plugin builder with QGIS?

I am using the plugin "plugin builder" to generate a template. The plugin builder is also generating a make file. I am working on a computer using windows 7 and am trying to execute the make file using the command line of Windows (MS Dos). However, this doesen't work. This means that my *.ui and my *.qrc file are not compiled to python, if I understand correctly.
What can I do? I am not very familiar with pc or programming so I hope to finde someone who can give me an easy understandable answer. Thank you.
Run the code in the osgeo4w Shell
And follow the steps in here:
http://www.qgisworkshop.org/html/workshop/plugins_tutorial.html
If the osgeo4w shell doesn't work copy the qtcore4.dll and qtgui4.dll to the windows system directory first
Regards
'make', works in linux by default as it is part of its build system. For windows, you could try downloading GNU Make Setup from below link
GNU make link
afterwards, you should be able to run 'make' from your dos prompt