MATLAB: Do I receive an error about the EDITOR environment variable when running MATLAB in nodisplay mode

displayeditorMATLABunix

Why do I receive an error about the EDITOR environment variable when running MATLAB in nodisplay mode?
When I run MATLAB in nodisplay mode and try to run the editor, I receive the following error:
Error: Environment variable EDITOR is not set.
??? Error using ==> system_dependent
Unknown service.
Error in ==> /devel/archive/R13/fcs/ship/unix/install/all/toolbox/matlab/general/edit.m (editor)
On line 249 ==> system_dependent('miedit', '');
Error in ==> /devel/archive/R13/fcs/ship/unix/install/all/toolbox/matlab/general/edit.m
On line 35 ==> errMessage = editor;

Best Answer

This is an intended behavior. To use the MATLAB Editor, you must run MATLAB with a display. You can do this by setting your DISPLAY environment variable or by starting MATLAB without the -nodisplay option.
Here are some instructions on how this could be done:
1) Start MATLAB from the Terminal Window in -nodisplay mode.
% matlab -nodisplay
2) Once MATLAB starts in the terminal use the SETENV and GETENV function to explore/change the environment variables.
3) To get the current variable value:
>> getenv EDITOR
4) To change it use the following:
>> setenv('EDITOR','emacs');
>> edit % this should launch the Emacs editor.