help-octave
[Top][All Lists]
Advanced

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

Re: How to import string and numerical data with arbitrary number of col


From: João Rodrigues
Subject: Re: How to import string and numerical data with arbitrary number of columns
Date: Sun, 01 Sep 2013 23:13:43 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8

On 01-09-2013 14:56, Markus Bergholz wrote:

What I really wanted was an alternative to textread that would do something like:

res = textread(filename,"%s %s %f")

and would create res as a cell whose columns were the different objects returned by textread  (in this case two string cell vectors and one numerical vector).
try this function

and if you just need the floating numbers, use dlmread like this:  res = dlmread ("data"," ", 0, 2); %skip 2 columns

Thanks for the tips.

The stackoverflow function involves an fgetl loop, which I wanted to avoid, but the dlmread is probably a good idea:

I can do textread to a string cell vector, reshape and discard the numerical part, and separately use dlmread to get the floating numbers as a numerical array. That way it's possible to avoid eval, loops and cellfun.

All the best,
joao

reply via email to

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