How i can open matlab file from terminal to edit it?

I run my file on gpu and when, write "type file name" command it open the file but no editing so, how can i edit the file?

2 Comments

Jan
Jan on 7 Dec 2017
Edited: Jan on 7 Dec 2017
What does "running a file on gpu" mean? Where do you write "type file name" and what do you expect as result? Where does the file open and what kind of "Matlab file" are you talking of - an M-file? What kind of "terminal" do you mean.
Please explain the details more clearly.
i use Putty program to access gpu server, i don't able to see desktop

Sign in to comment.

 Accepted Answer

You can open an M-file in Matlab by typing
edit File.m
If it is not in the current path add the path name also. Alternatively you can click on the "Open" button in the menu. A double click on the M-file opens it in the editor also.
But see my questions for clarifications in the comment above.

8 Comments

i use Putty program to access gpu server, i don't able to see desktop & i already use edit command but have the following error Error: Environment variable EDITOR is not set. Error using edit (line 64) "Unknown service"
And it is really useful to edit the code over the terminal on the remote machine? What kind of OS is the remote machine running? Perhaps vi or nano helps you?
And does the suggested nano or vi help?
You want an editor in the terminal and this question has no relation to Matlab. Asking an internet search engine for "edit text file ubuntu" should help also.
but i think matlab file have extension .m not .txt
Jan
Jan on 8 Dec 2017
Edited: Jan on 8 Dec 2017
@mohammed: The file extension is a set of characters only. You can even use .ycxvsfad and open the file as text file. M-files are text files and all you find in them are characters. So you can simply open them with a standard text editor. Simply try it.
Related question:
Let's say you want to open a .m file in textedit from a bash terminal. You'd write:
open -a "TextEdit" scriptName.m
Now, let's say you were working in terminal and wanted to open a script in matlab when matlab isn't open. I tried:
open -a "Matlab" scriptName.m
As well as "MATLAB" and "matlab", but both did not work.
Ideally, one could write a command that opens matlab, makes the current folder of matlab the same path as the current terminal directory, then opens a specified file in editor.
Thanks for your help.
When you start MATLAB, specify the -sd startup option to control where MATLAB starts and specify the -r option to run the command "edit(nameOfFile)" replacing nameOfFile with the file you want to open.
While I've linked the Linux startup options list above, Windows and Mac OS also support both those options. See the other pages linked in the See Also from the page above for OS-specific startup options (mainly the COM-related options on Windows, I believe.)

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!