[Top][All Lists]

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

Re: text and numbers

From: Daniel Heiserer
Subject: Re: text and numbers
Date: Thu, 18 Feb 1999 08:59:44 +0100

Huaiyu Zhu wrote:
> What's the best way to input text and data from the same file?
> This does not work:
> data = [
> 'name1' 12 34
> 'name2' 56 78
> ];
> I want to input a structure that has both text and numbers, and then
> separate out submatrices.  Of course I can use perl and friends to
> separate them into two files and input them separately, but that
> introduces consistency issues.
> I remember asking this question about matlab once, but can't locate the
> answer now.  Is octave behaving similarly to matlab in this regard?
> Thanks.

Try fscanf and friends. 
The fastest way probably ist to do a 

fread;reshape according to "\n" extract the columns you want and do a
eval or fscanf on
it to get the numerical values if wanted.
For such things I NEVER go into octave or matlab. 
Perl is the fastest AND most convenient way to do that. 
Just include a perl script via "system" in a m-file which produces
some files "/tmp/a.ascii, /tmp/b.ascii" and an additional m-file
which says: "load /tmp/b.ascci;load /tmp/a.ascii" 
and so on.

#my m-perl files
system(" stuff");

load /tmp/b.ascci;load /tmp/a.ascii


Mit freundlichen Gruessen
                                 Daniel Heiserer
Dipl.-Phys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820

reply via email to

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