no obvious variable name using 'load'

Ben Abbott bpabbott at mac.com
Sat Dec 20 15:34:02 CST 2008


On Dec 20, 2008, at 4:03 PM, Sergei Steshenko wrote:

> Hello,
>
> this is what 'help load' (among other things) says:
>
> "
>   `-ascii'
>          Force Octave to assume the file contains columns of numbers
>          in text format without any header or other information.  Data
>          in the file will be loaded as a single numeric matrix with
>          the name of the variable derived from the name of the file.
> ".
>
> And this is my experiment:
>
> "
> octave:1> system("echo 1234567890 > doo.dah.txt;cat doo.dah.txt");
> 1234567890
> octave:2> load('-ascii', 'doo.dah.txt');
> octave:3> doo
> error: `doo' undefined near line 3 column 1
> octave:3> doo.dah
> error: `doo' undefined near line 3 column 1
> octave:3> dah
> error: `dah' undefined near line 3 column 1
> octave:3> version
> ans = 3.0.3
> octave:4>
> ".
>
> On the one hand, I see no error or warning message due to 'load'  
> command,
> on the other hand I see no way to deduce the variable name.
>
> I think a version of 'load' which returns a value is necessary.
>
> Thanks,
>  Sergei.

octave:1>  system("echo 1234567890 > doo.dah.txt;cat doo.dah.txt");
1234567890
octave:2> load('-ascii', 'doo.dah.txt');
octave:3> who

*** dynamically linked functions:

builtin:find  builtin:max   builtin:min   cellfun       dispatch       
getpwuid      sort

*** currently compiled functions:

compare_versions  isa               logical            
str2num           version
edit              ismember          pkg                
strcat            xor
findstr           ispc              repmat            strfind
fullfile          isscalar          split             strrep

*** local user variables:

__nargin__  ans         doo_dah

octave:4> doo_dah
doo_dah =  1.2346e+09
octave:5>

and in Matlab 2008b

 >> load('-ascii','doo.dah.txt')
 >> who

Your variables are:

doo_dah

 >>

Without "who" it is not obvious, but all appears to be working  
correctly.

Ben


Ben



More information about the Bug-octave mailing list