help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loading a filename beginning with a digit


From: avraham.rosenberg
Subject: Re: loading a filename beginning with a digit
Date: Mon, 21 Jul 2003 00:14:14 -0500

Hi,
In my experience, if you wish to load data from a text file to some
arbitrarily named array, in a script, load is not the most convenient
tool. I use, instead the c-type input functions.

example:        fid1=fopen("file_name","r");
                array_name==fscanf(fid1,"%f %f\r",[2,inf]); %assuming you
have two colums of data
                fclose(fid1); %this is not indispensable. Just good old
habits.

Cheers, Avraham

On Sun, 20 Jul 2003, Mike Miller wrote:

> Suppose, for example, that I have a file named 2x.txt with these contents:
> 
> 1 3
> 9 5
> 
> (Just two lines with two integers per line, but in real life I'll want to
> do this with larger files!)  When I load the file, I am not able to access
> the data.  (Please don't tell me to rename the file!  I just want to make
> the load function work within a script I'm writing no matter what the
> filename, if that's possible.)  I did this in a couple of versions of
> Octave on Solaris 8:
> 
> 
> octave:1> load 2x.txt
> octave:2> whos
> 
> *** local user variables:
> 
> prot  type               rows   cols  name
> ====  ====               ====   ====  ====
>  wd   matrix                2      2  2x
> 
> octave:3> 2x
> parse error:
> 
> >>> 2x
>      ^
> 
> octave:3> "2x"
> ans = 2x
> octave:4> eval("2x")
> parse error:
> 
> >>> 2x
>      ^
> 
> error: evaluating index expression near line 4, column 1
> 
> 
> So, Octave seems to load the 2x2 matrix, but I just can't figure out how
> to get at it.  (I thought Octave didn't allow variables beginning with a
> digit.)  I'd really like to be able to rename the loaded matrix, but how?
> 
> Thanks in advance for any tips!
> 
> Mike
> 
> -- 
> Michael B. Miller, Ph.D.
> Assistant Professor
> Division of Epidemiology
> and Institute of Human Genetics
> University of Minnesota
> http://taxa.epi.umn.edu/~mbmiller/
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
> 
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]