help-octave
[Top][All Lists]
Advanced

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

Re: request for help with textread


From: PhilipNienhuis
Subject: Re: request for help with textread
Date: Sat, 7 Sep 2013 07:09:13 -0700 (PDT)

Kristoffer Walker wrote
> Hello,
> 
> I have recently installed octave 3.6.1 on Linux Mint v. 13 (version of 
> Ubuntu 12).  Data file "test.in":
> 
> 1336 901
> 0.000000 0.000000 0.3329580775 -0.0022473728 -0.0008216525
> 0.000000 0.200000 0.3320154915 -0.0023726505 -0.0009491121
> 
> [x10,y10]=textread("test.in","%f %f%*[\n]","headerlines",1);
> error: textread: A(I): index out of bounds; value 1 out of bound 0
> error: called from:
> error:   /usr/share/octave/3.6.1/m/io/textread.m at line 75, column 3
> <snip>
> Can someone tell me what I am doing wrong?  I read the help page
> completely.

Maybe first of all you installed a too old version of Octave?
The stable version has been 3.6.4 for quite a while. I think the bug (index
out-of-bound) has been fixed since 3.6.1, I vagely remember that.

But anyway even with 3.6.4 and the development version it doesn't work.
After having put in some spaces for readability, textread.m shows me the
actual problem:

>> [x10, y10] = textread ("test.in", "%f %f%*[\n]", "headerlines", 1)
error: strread: %q, %c, %[] or bit width format specifiers are not supported
 yet.
error: called from:
error:   X:\Octave\octave-3.7.6+_MXE\share\octave\3.7.6+\m\io\strread.m at l
ine 308, column 7
error:   X:\Octave\octave-3.7.6+_MXE\share\octave\3.7.6+\m\io\textread.m at
line 180, column 31
>>

...which means that the %*[\n] format conversion specifier isn't supported.
Are you trying code written for Matlab? (seems so)

If you skip the rightmost 3 columns by using the "%*f" format, textread
works for the datafile you showed:

>> [x10, y10] = textread ("test.in", "%f %f %*f %*f %*f", "headerlines", 1)
x10 =

   0
   0

y10 =

   0.00000
   0.20000

>>

I you're brave, you could also try a patched strread.m (the work horse
behind textread.m) where I had implemented some of those missing format
conversion specifiers (notably [] and *[]) but with a lot of gotchas; I
don't remember clearly, it was quite a while ago. See here:

https://savannah.gnu.org/patch/?7817

I don't remember what versions of textread.m the patched strread.m will work
with - might be from around early 2012. Later versions probably catch the
"unsupported" format specifiers before handing the job to strread.m
You'll have to try yourself if you go this route.

Philip




--
View this message in context: 
http://octave.1599824.n4.nabble.com/request-for-help-with-textread-tp4657102p4657110.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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