3

I'm new to octave, and want to run a few commands on startup automatically every time it opens.

I typed "help startup" and saw "Octave uses the file ".octaverc". I did a bit of searching online at https://www.math.utah.edu/docs/info/octave_4.html, and saw the .octaverc file should be in the following path:

OCTAVE_HOME/lib/octave/VERSION/startup/octaverc

PROBLEM:

In that directory I don't have a startup folder, only "oct" and "site". I do see hidden files, which was my first thought since the file begins with "." character. So I then used Agent Ransack in the directory, and still nothing came up.

QUESTION:

1) Do I have to make the startup folder and octaverc file myself?

2) If so, does one, both or none have to be hidden?

3) Can it be a txt file, or does it have a special extension?

4) Do I just type the commands straight into the file or is there special formatting?

NOTE: In case I'm going about this the wrong way, there are the operations I'd like to have run on startup:

PS1('>> '), addpath('D:\Users\Me\Desktop'), clc

Thanks ahead of time for the help!!

EnigmaticBacon
  • 353
  • 6
  • 21

4 Answers4

4

Possible locations (and their differences) for octaverc files are specified in the documentation.

In short, these are, from more general to specific:

  • octave-home/share/octave/site/m/startup/octaverc (most generic, for entire system)
  • octave-home/share/octave/version/m/startup/octaverc (to cover for more than one octave versions installed on the system, possibly requiring different startup scripts)
  • ~/.octaverc (where ~ is unix-speak for a user's home directory -- covering for user-specific startup files)
  • .octaverc files in any directory, creating specific startup conditions for specific directories

octaverc files are effectively simple script files that are executed from most generic to most specific each time octave starts. Therefore, in the presence of conflicting commands, the more specific file can effectively be used to override the more generic behaviour.

Octave also supports (but does not recommend) the use of the startup.m file, for matlab compatibility.

You might also want to check out pathdef and savepath as well.

As a more general tip, if you ever want to search for a specific keyword from the documentation (e.g. octaverc), you can type this kind of search query in duckduckgo (or google):

octaverc site:https://octave.org/doc/interpreter/

(or just download the documentation as pdf and search the pdf)

Tasos Papastylianou
  • 21,371
  • 2
  • 28
  • 57
1

Searching for the octave windows startup file location points to this thread.

Place files within %appdata% on windows7. I created ".octaverc" and "startup.m" and they were run on startup.

pathfinder
  • 106
  • 1
  • 8
0

Found the solution, the file was in the following path:

OCTAVE_HOME/share/octave/site/m/startup

to find out where OCTAVE_HOME is for you, just type "OCTAVE_HOME" into your Octave command line window.

ANSWERS:

1) You do not have to make a startup octaverc file yourself

2) The file is actually not hidden, so it should be easy to find given you're looking in the right place.

3) The file doesn't have an extension. It's just octaverc.

4) Under the last line of the existing file, you can just append commands as you would type them at the Octave command line window.

EnigmaticBacon
  • 353
  • 6
  • 21
0

the last(7.3.0) octave version placed HERE:/ does not find the THERE:/openEMS/matlab directory even it is already loaded with octaverc or addpath. It keeps looking into the work dir where openEMS is not placed and does not recognize, for instance, the 'physical_constants.m' file.

m.e.
  • 1