Thread Subject: textread with endoflines

Subject: textread with endoflines

From: kates

Date: 11 Nov, 2008 01:10:34

Message: 1 of 3

Dear Matlaber

I have sensor data reading as follows:

-SENSOR/DESCRIPTION
*-------------------------
 GOLD 08:01:00 108.5
 GOLD 08:01:06 086.6
 GOLD 08:01:12 085.0
 GOLD 08:01:18 080.3
 -/ Finish
 + (c) thank you

I use the following syntax to read the data (in txt file):
[sensor,hour,min,sec,param]=textread('sensor.txt','%4s %2d:%2d:%2d %f','delimiter',',','headerlines',2,'endofline','\n');

Output: ??? Trouble reading literal string from file (row 1, field 5) ==> 1:00 108.5\n

Do you have another way? Your time to response this small problem is appreciated.

==kate

Subject: textread with endoflines

From: Richard Brown

Date: 11 Nov, 2008 01:39:07

Message: 2 of 3

On Nov 11, 2:10=A0pm, kates <wa...@ukm.my> wrote:
> Dear Matlaber
>
> I have sensor data reading as follows:
>
> -SENSOR/DESCRIPTION
> *-------------------------
> =A0GOLD 08:01:00 108.5
> =A0GOLD 08:01:06 086.6
> =A0GOLD 08:01:12 085.0
> =A0GOLD 08:01:18 080.3
> =A0-/ Finish
> =A0+ (c) thank you
>
> I use the following syntax to read the data (in txt file):
> [sensor,hour,min,sec,param]=3Dtextread('sensor.txt','%4s %2d:%2d:%2d %f',=
'delimiter',',','headerlines',2,'endofline','\n');
>
> Output: ??? Trouble reading literal string from file (row 1, field 5) =3D=
=3D> 1:00 108.5\n
>
> Do you have another way? Your time to response this small problem is appr=
eciated.
>
> =3D=3Dkate

Can I suggest you use textscan instead?
fid =3D fopen('sensor.txt', 'r')
C =3Dtextscan(fid, '%s %d:%d:%d %f\n', 'headerlines', 2)
fclose(fid)

C is a cell array of vectors containing the various things ... e.g.
C{1} would be sensor, C{2} hour, C{3} minute, etc.

Hope that helps,

Richard

Subject: textread with endoflines

From: kates

Date: 11 Nov, 2008 03:16:32

Message: 3 of 3

Dear Richard

Well done. Your idea very wonderful.

See you next time. Thank you very much.

==Kate

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com