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: Kristoffer Walker
Subject: Re: request for help with textread
Date: Sat, 07 Sep 2013 12:12:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8

Philip,

First off, thank you for the quick response, and on the weekend. Secondly, thanks so much for developing textread. It is an extremely useful program.

I'm not brave, so I'll work with the stock strread. But I will endeavor to install 3.6.4 for the workaround you pointed out. However, when I first tried to install octave on Linux Mint, the default installation was version 3.2 if I recall correctly. This version did not have textread. So after googling around, I learned to do this to install 3.6:

sudo apt-add-repository -y ppa:picaso/octave
sudo apt-get update
sudo apt-get install octave
sudo apt-get install liboctave-dev

That installed version 3.6.1. Is there a similar set of commands that will enable me to install 3.6.4? If not, maybe compiling it from source is not a painful experience?

Thank you,
Kris


On 09/07/2013 07:09 AM, PhilipNienhuis wrote:
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.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave





reply via email to

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