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:
How Convert TXT data format to MAT data format

Subject: How Convert TXT data format to MAT data format

From: Putrisia Hendra

Date: 5 Aug, 2010 03:26:04

Message: 1 of 9

I have a EEG's data in txt format..
but now, i want to convert it to mat data format
can i do that?

this is because of Matlab can read more faster if the data i convert to MAT data format

Subject: How Convert TXT data format to MAT data format

From: Walter Roberson

Date: 5 Aug, 2010 04:29:23

Message: 2 of 9

Putrisia Hendra wrote:
> I have a EEG's data in txt format..
> but now, i want to convert it to mat data format
> can i do that?
>
> this is because of Matlab can read more faster if the data i convert to
> MAT data format

Although it would be theoretically possible to do the conversion outside
of matlab, the amount of time it would take to write and debug the
appropriate program would be completely unproductive. Just enter matlab
and load the file; if you will need to load it again another time then
it might be worth saving the contents as a MAT file.

Subject: How Convert TXT data format to MAT data format

From: gorkemsvs@gmail.com

Date: 26 Dec, 2012 01:19:48

Message: 3 of 9


hello Putrisia.

Im having the same problem.but im not convert the eeg text file to mat file.

how did you convert this?

I hope,you help me.Thank you so much.

Subject: How Convert TXT data format to MAT data format

From: gorkemsvs@gmail.com

Date: 26 Dec, 2012 01:29:33

Message: 4 of 9

I am trying to save .mat format.
But matlab have an error.
"Error using load
Unable to read MAT-file myeegdata.mat: not a binary
MAT-file.
Try LOAD -ASCII to read as text."

can u help me?
thank you.

Subject: How Convert TXT data format to MAT data format

From: dpb

Date: 26 Dec, 2012 01:47:15

Message: 5 of 9

On 12/25/2012 7:29 PM, gorkemsvs@gmail.com wrote:
> I am trying to save .mat format.
> But matlab have an error.
> "Error using load
> Unable to read MAT-file myeegdata.mat: not a binary
> MAT-file.
> Try LOAD -ASCII to read as text."
>

Well, clearly it isn't a recognizable .mat file.

Did you try Matlab's suggestion?

Was the file written from Matlab or is it just a stream file or some
other format from some other source?

--

Subject: How Convert TXT data format to MAT data format

From: gorkemsvs@gmail.com

Date: 26 Dec, 2012 05:22:08

Message: 6 of 9


> Well, clearly it isn't a recognizable .mat file.
>
>
>
> Did you try Matlab's suggestion?
>
>
>
> Was the file written from Matlab or is it just a stream file or some
>
> other format from some other source?



My file is a text file.I opened the text file with matlab an i saved the file .mat format.But then i didn't open the .mat file in matlab.
My file contains numeric data.I guess I was an error saving the file.

sorry for my english thank you

Subject: How Convert TXT data format to MAT data format

From: TideMan

Date: 26 Dec, 2012 20:00:25

Message: 7 of 9

On Wednesday, December 26, 2012 6:22:08 PM UTC+13, gork...@gmail.com wrote:
> > Well, clearly it isn't a recognizable .mat file.
>
> >
>
> >
>
> >
>
> > Did you try Matlab's suggestion?
>
> >
>
> >
>
> >
>
> > Was the file written from Matlab or is it just a stream file or some
>
> >
>
> > other format from some other source?
>
>
>
>
>
>
>
> My file is a text file.I opened the text file with matlab an i saved the file .mat format.But then i didn't open the .mat file in matlab.
>
> My file contains numeric data.I guess I was an error saving the file.
>
>
>
> sorry for my english thank you

What do you mean when you say "I opened the text file..."?
Do you mean:
fid=fopen('myfile.txt','rt'):
If so, what did you do then?

Before you can save the data to a .mat file, you must read them into Matlab using something like textscan.
Then you can write them off to a .mat file using save.

Subject: How Convert TXT data format to MAT data format

From: gorkemsvs@gmail.com

Date: 26 Dec, 2012 22:20:43

Message: 8 of 9

Thanks for helping.



 fid = fopen('mydata.txt');
            C = textscan(fid, '%s%s%f32%d8%u%f%f%s%f');
            fclose(fid);


the code ,that you gave me which was wroten at the top of this sentence,is only used for matrixes which columns and lines are specific. but I have a lot of matrixes which have different numbers of columns and lines in my textscan. So I need a code which can sense all different types of matrixes automatic.

Thank you for all helping.

Subject: How Convert TXT data format to MAT data format

From: dpb

Date: 26 Dec, 2012 22:53:15

Message: 9 of 9

On 12/26/2012 4:20 PM, gorkemsvs@gmail.com wrote:
...

> C = textscan(fid, '%s%s%f32%d8%u%f%f%s%f');
...

>
> the code ,that you gave me which was wroten [written] ...
> ... I have a lot of matrixes which have different numbers of
> columns and lines in my textscan. So I need a code which can sense all
> different types of matrixes automatic.
...

No can do if it's arbitrary unless you have additional
information--either a header record in the file that identifies the file
structure that can then be used or read a line and identify fields on a
field-by-field basis before reading the rest of the file.

There's no magic elixir, sorry...

--

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