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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com