Time for action - creating an Octave home directory under Windows
Let us assume that the Octave home directory is going to be C:\Documents and Settings\GNU Octave\
. We can actually create this directory directly from Octave; so let us go ahead.
1. Start Octave and give it the following commands:
octave:1> cd C: octave:2> cd "Documents and Settings" octave:3> mkdir "GNU Octave" ans = 1
2. The response ans = 1 after the last command means that the directory was successfully created. If Octave returns a zero value, then some error occurred, and Octave will also print an error message. Instead of creating the directory through Octave, you can use, for example, Windows Explorer.
3. We still need to tell the interpreter that this is now the Octave home directory. Let us do this from Octave as well:
octave:4> edit
4. You should now see an editor popping up. The default editor under Windows is Notepad++. Open the file
c:\octave-home\share\octave\site\m\startup\octaverc
, whereoctave-home
is the path where Octave was installed, for example,Octave\3.2.4_gcc-4.4.0
. Add the following lines at the end of the file.setenv('HOME', 'C:\Document and Settings\GNU Octave\'); cd ~/
Be sure that no typos sneaked in!
5. Save the file, exit the editor, and restart Octave. That is it.
Note
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
What just happened?
The first three Octave commands should be clear: we changed the directory to C:\Documents and Settings\
and created the directory GNU Octave
. After this, we opened the global configuration file and added two commands. The next time Octave starts it will then execute these commands. The first instructed the interpreter to set the home directory to C:\Document and Settings\GNU Octave\
, and the second made it enter that directory.
Creating your first .octaverc file
Having created the Octave home directory under Windows, we can customize Octave under GNU/Linux and Windows the same way.