[Top][All Lists]

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

Re: Importing data problems

From: Przemek Klosowski
Subject: Re: Importing data problems
Date: Wed, 30 Sep 2009 14:11:01 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3

On 09/30/2009 05:32 AM, s4y asked why the code:
[fid] = fopen("test2.txt", "r", "native");
[m, count] = fscanf(fid, "%f:%f:%f %f %f %f %f %f %f",[2,9]);

incorrectly chops up the following data file

16:09:06   32.41   32.63   36.43    36.63   36.65   34.56
16:09:13   32.39   35.63   46.43    66.83   26.65   34.56

The best way to think about it is that fscanf() reads a stream of data into a single column, which can then be reshaped. You ask for a [2,9] form, which chops 2-row-long columnar pieces and assembles them into 9 columns. If you do

[m, count] = fscanf(fid, "%f:%f:%f %f %f %f %f %f %f",[9,2]);

and transpose ( m' ) you will get your desired result.

reply via email to

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