Fri 06 Jan 2012 05:24:25 PM UTC, original submission:
When saving a (binary) file in octave and loading it in the same session, all variables are loaded correctly. Example:
octave:1> octave_path; constants;
octave:2> who
Variables in the current scope:
Ang c0au mAr mCl mLi6 mO18
Debye cm1 mB mCl37 mMg mP
Debye_g98 coulomb mB10 mD mN mS
GHz eV mBe mF mN15 mSi
MHz g_e mBr mH mNa mXe
NA gauss mBr79 mHe mNe second
Vcm1 joule mBr81 mHe3 mNe21 tesla
amu kboltz mC mI mNe22
ans kcal mC13 mK mO
c0 mAl mCa mLi mO17
octave:3> Ang
Ang = 1.8897
octave:4>
octave:4> save('x.mat','-binary')
octave:5> clear all
octave:6> who
octave:7> load('x.mat')
octave:8> who
Variables in the current scope:
Ang c0au mAr mCl mLi6 mO18
Debye cm1 mB mCl37 mMg mP
Debye_g98 coulomb mB10 mD mN mS
GHz eV mBe mF mN15 mSi
MHz g_e mBr mH mNa mXe
NA gauss mBr79 mHe mNe second
Vcm1 joule mBr81 mHe3 mNe21 tesla
amu kboltz mC mI mNe22
ans kcal mC13 mK mO
c0 mAl mCa mLi mO17
octave:9> exit
(all of these variables are floating point numbers; see attached file constants.m)
Now, when starting a new octave session and reloading the file x.mat, some variables are missing (in this example e.g. Ang, amu, c0, ...):
octave:1> who
Variables in the current scope:
ans
octave:2> load('x.mat')
octave:3> who
Variables in the current scope:
Debye c0au mB mCa mMg mO18
Debye_g98 coulomb mB10 mCl37 mN15 mP
GHz g_e mBe mHe3 mNa mSi
MHz gauss mBr mI mNe mXe
NA joule mBr79 mK mNe21 second
Vcm1 kboltz mBr81 mLi mNe22 tesla
ans mAl mC13 mLi6 mO17
However, the missing variable(s) can be loaded correctly if the corresponding variable name is first initialized. Example:
octave:4> Ang
error: `Ang' undefined near line 4 column 1
octave:4> Ang=1
Ang = 1
octave:5> load('x.mat')
octave:6> Ang
Ang = 1.8897
octave:7> who
Variables in the current scope:
Ang ans mAl mC13 mLi6 mO17
Debye c0au mB mCa mMg mO18
Debye_g98 coulomb mB10 mCl37 mN15 mP
GHz g_e mBe mHe3 mNa mSi
MHz gauss mBr mI mNe mXe
NA joule mBr79 mK mNe21 second
Vcm1 kboltz mBr81 mLi mNe22 tesla
(note that only Ang is added, other variables such as amu and c0 are still missing)
The problem seems to be independent of file format; omitting the '-binary' flag, or using e.g. '-v7', makes no difference.
The saving and loading is done in the same version of octave, so this is not a compatibility issue between different versions.
|