Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
restructure the data

Subject: restructure the data

From: edward kabanyas

Date: 29 Oct, 2012 02:34:08

Message: 1 of 1

Hi all,

I need to read the following data, as example:

10-Apr-2004 00:00:00
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
10-Apr-2004 00:08:06
21.3 21.3 21.2 21.2
20.8 20.9 21.1 21.2
20.6 20.7 20.9 21.1

and soon..

The output that I need is as cell,

Cell-1=
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
Cel-2=
21.3 21.3 21.2 21.2
20.8 20.9 21.1 21.2
20.6 20.7 20.9 21.1

So far, I read as:

% the data
     fnam='test.txt';
% the engine
     s=textread(fnam,'%s','delimiter','\n');
     tmpl='10-Apr-2004';
     ix=false(size(s,1),1);
     ix(strncmp(tmpl,s,numel(tmpl)))=true;
     ix=find(ix);

By this way, I know the position of '10-Apr-2004' and cut the data in between so that I have:

Cell-1=
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
Cel-2=
21.3 21.3 21.2 21.2
20.8 20.9 21.1 21.2
20.6 20.7 20.9 21.1

However, these two cells are still as character/string, I need them as float/double. Probably, you know better method to restructure these data ? Thank you for share..

Edward

Tags for this Thread

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.

Contact us