PDA

View Full Version : Launching matlab in nautilus: simple operations (open m-file, prescribe wd)


aimonas
November 3rd, 2009, 06:20 PM
hello everyone! I would like to share and at the same time book-keep a few things that have made my life easier while using matlab under ubuntu.

1. open m-file with matlab through nautilus

The concept is to assign a default custom command to open m-files. This is done through right-click-->properties>open with tab-->add-->use a custom command, at which point we input

matlab -desktop -r "edit %f"

This action however, opens matlab and the editor with the desired file loaded, but leaves the working directory to its default value. I haven't found a way to change the directory simultaneously, so if anyone could give any clue it would be nice.

2. click on m-file and open matlab at the respective directory

Same procedure as previously, but we input the following command

matlab -desktop -r "cd %d"

3. navigate to any folder in the filesystem and open matlab to work in that specific folder

a. prepare a small script (let's name it matcd) as follows:


#!/bin/sh
matlab -desktop -r "cd %d"


b.render it executable through right-click-->properties-->permissions

c. copy it to ~/.gnome2/nautilus-scripts/ and restart system or log out and log back in

then by right clicking inside any folder you can find the script in the submenu scripts. running it will perform the desired action

hope this is useful

cheers

PGScooter
November 5th, 2009, 01:16 AM
thank you! I've pretty much switched to R now, but I still use matlab on occasion for old scripts.

xapuka
November 26th, 2009, 11:06 AM
Hi,

thanks for the tip! Just one thing, I HAD to use the -desktop flag. Without it doesn't work. By the way, I'm using Matlab 7.50 (R2007b)

Cheers,

xapuka

monguin61
December 16th, 2009, 02:04 PM
Thanks for the tips. Does anyone know how to open an m-file with a currently-open matlab session?

perroazul
December 16th, 2009, 04:15 PM
Thanks for the tips. Does anyone know how to open an m-file with a currently-open matlab session?

using matlab's file browser I believe

aimonas
December 16th, 2009, 05:07 PM
through the command window you can use

edit filename.m

this applies also when you run matlab through the terminal

cheers

monguin61
December 16th, 2009, 05:27 PM
through the command window you can use

edit filename.m

this applies also when you run matlab through the terminal

cheers



Sorry, I meant to ask if it is possible to open an m-file, through Nautilus (or some other file browser), in the current Matlab session. This works in Windows Explorer and I'm hoping I can get the same functionality in Ubuntu.

Thanks.