Aquiles Páez
Aquiles Páez

Reputation: 573

Issue reading .txt file in Matlab. I want to get an array from this file without the unnecessary info it contains

I'm having trouble reading a .txt file to get some data. I want to be able to change some of the values this data contains.

At first, I used this:

    A=importdata('myfile.txt');

And got this cell array:

enter image description here

Now what I want is this:

1) Get rid of the headers (the information from cell 1 to 22). That could be easily done by simple indexing (creating a sub-array using just the info from cell 23 to the end of the file).

2) I want to separate the information into different cells, using these identifiers. But I don't know how to separate them into different cells of the array.

'# item  bepoch   ecode             label         onset           diff       dura   b_flags    a_flags    enable        bin'

3) Do the same in step 2 to fill those columns with the data in the rest of the cells.

I'm trying to use this approach, but I'm not getting the expected results.

If someone can help me, I'd be glad.

Upvotes: 0

Views: 37

Answers (1)

Ad_S
Ad_S

Reputation: 11

Have you tried dragging the file into the variable workspace window and using the data import wizard? It has some nice features that normally take care of what you are trying to do automatically. Unfortunately, it seems that your text file may have unconventional spacing, but Matlab may be able to handle it if you set the delimeter to ' ' or suchlike.

Upvotes: 1

Related Questions