Discussion:
save/load loses dimension info?
(too old to reply)
Randy Yates
2007-07-10 03:07:39 UTC
Permalink
I used "save -binary 'H.dat' H" to save a 2x4095 matrix. When I reload
it using H=load('H.dat'), the dimension information is gone and
size(H) returns (1,1), but the strange thing is if you simply type "H"
to dump its contents, it's all there.

version 2.9.9 on
Linux localhost.localdomain 2.6.20-1.2948.fc6 #1 SMP Fri Apr 27 19:18:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
--
% Randy Yates % "Maybe one day I'll feel her cold embrace,
%% Fuquay-Varina, NC % and kiss her interface,
%%% 919-577-9882 % til then, I'll leave her alone."
%%%% <***@ieee.org> % 'Yours Truly, 2095', *Time*, ELO
http://home.earthlink.net/~yatescr
david bateman
2007-07-10 13:14:46 UTC
Permalink
Post by Randy Yates
I used "save -binary 'H.dat' H" to save a 2x4095 matrix. When I reload
it using H=load('H.dat'), the dimension information is gone and
size(H) returns (1,1), but the strange thing is if you simply type "H"
to dump its contents, it's all there.
version 2.9.9 on
Linux localhost.localdomain 2.6.20-1.2948.fc6 #1 SMP Fri Apr 27 19:18:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
--
% Randy Yates % "Maybe one day I'll feel her cold embrace,
%% Fuquay-Varina, NC % and kiss her interface,
%%% 919-577-9882 % til then, I'll leave her alone."
Under Octave 2.9.12 I see

octave:2> version
ans = 2.9.12
octave:3> H = rand(2,4095);
octave:4> save -binary H.dat H
octave:5> clear H
octave:6> load H.dat
octave:7> whos H

*** local user variables:

Prot Name Size Bytes Class
==== ==== ==== ===== =====
rwd H 2x4095 65520 double

Total is 8190 elements using 65520 bytes

Maybe you shouldn't surround the H.dat is the inverted commas.... This
is the command form, and so all arguments are already treated as
strings..

D.
Randy Yates
2007-07-10 15:36:28 UTC
Permalink
Post by david bateman
Post by Randy Yates
I used "save -binary 'H.dat' H" to save a 2x4095 matrix. When I reload
it using H=load('H.dat'), the dimension information is gone and
size(H) returns (1,1), but the strange thing is if you simply type "H"
to dump its contents, it's all there.
version 2.9.9 on
Linux localhost.localdomain 2.6.20-1.2948.fc6 #1 SMP Fri Apr 27 19:18:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
--
% Randy Yates % "Maybe one day I'll feel her cold embrace,
%% Fuquay-Varina, NC % and kiss her interface,
%%% 919-577-9882 % til then, I'll leave her alone."
Under Octave 2.9.12 I see
octave:2> version
ans = 2.9.12
octave:3> H = rand(2,4095);
octave:4> save -binary H.dat H
octave:5> clear H
octave:6> load H.dat
octave:7> whos H
Prot Name Size Bytes Class
==== ==== ==== ===== =====
rwd H 2x4095 65520 double
Total is 8190 elements using 65520 bytes
Maybe you shouldn't surround the H.dat is the inverted commas.... This
is the command form, and so all arguments are already treated as
strings..
That wasn't it. Your version of the command produces the exact same result.

I found that octave is reading H as a structure with a single field, 'H'.
If I execute

octave:100>HNew=getfield(H,'H');

then HNew is an array with the correct dimensions.

Maybe this was a bugfix between 2.9.9 and 2.9.12?
--
% Randy Yates % "And all that I can do
%% Fuquay-Varina, NC % is say I'm sorry,
%%% 919-577-9882 % that's the way it goes..."
%%%% <***@ieee.org> % Getting To The Point', *Balance of Power*, ELO
http://home.earthlink.net/~yatescr
Randy Yates
2007-07-10 15:42:50 UTC
Permalink
Post by Randy Yates
Post by david bateman
Post by Randy Yates
I used "save -binary 'H.dat' H" to save a 2x4095 matrix. When I reload
it using H=load('H.dat'), the dimension information is gone and
size(H) returns (1,1), but the strange thing is if you simply type "H"
to dump its contents, it's all there.
version 2.9.9 on
Linux localhost.localdomain 2.6.20-1.2948.fc6 #1 SMP Fri Apr 27 19:18:54 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
--
% Randy Yates % "Maybe one day I'll feel her cold embrace,
%% Fuquay-Varina, NC % and kiss her interface,
%%% 919-577-9882 % til then, I'll leave her alone."
Under Octave 2.9.12 I see
octave:2> version
ans = 2.9.12
octave:3> H = rand(2,4095);
octave:4> save -binary H.dat H
octave:5> clear H
octave:6> load H.dat
octave:7> whos H
Prot Name Size Bytes Class
==== ==== ==== ===== =====
rwd H 2x4095 65520 double
Total is 8190 elements using 65520 bytes
Maybe you shouldn't surround the H.dat is the inverted commas.... This
is the command form, and so all arguments are already treated as
strings..
That wasn't it. Your version of the command produces the exact same result.
I found that octave is reading H as a structure with a single field, 'H'.
If I execute
octave:100>HNew=getfield(H,'H');
then HNew is an array with the correct dimensions.
Maybe this was a bugfix between 2.9.9 and 2.9.12?
No no no!

I got it, damn it.

H = load('-binary','H.dat');

is NOT the same as

load('-binary','H.dat');

!!!!!
--
% Randy Yates % "The dreamer, the unwoken fool -
%% Fuquay-Varina, NC % in dreams, no pain will kiss the brow..."
%%% 919-577-9882 %
%%%% <***@ieee.org> % 'Eldorado Overture', *Eldorado*, ELO
http://home.earthlink.net/~yatescr
Continue reading on narkive:
Loading...