load physical constants into octave -
I was wondering if it is possible to create a file containing all the common constants that I use, and all of them Load at octave at once.
Basically every time I use Octave, I have to open my text file in which it has SI value for some physical constants, and then copy and paste it into my File I was wondering if there was any way I could avoid this work, and just type "load filename" as if I import the data, and then all my constants will be defined in one step?
Here's a way:
Suppose a file defines a constant That's the script called Place this file in a known directory. For example, I will put it in the subdirectory of my home directory called Edit the file (or create, if it does not exist). Octaverc in your home directory, and add the line Now start the oksav to load definitions, and constants.m . Ex:
avogadro = 6.02214179e23; Gravity_accel = 9.80665; Light_speed = 299792458;
local_octave .
addpath (& lt; path_to_known_directory & gt;) , but
& lt; Path_to_known_directory & gt; With the place of , OK, what it says on my computer, I've added the
addpath ("~ / local_octave") .
constant code> constants.m . E.g.
Access: 1> Avogadro error: 1 column 1 oxide near undefined line 'avogadro': 1> Constant Octagon: 2 & gt; Avogadro avogadro = 6.0221e + 23
Comments
Post a Comment