Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How Convert TXT data format to MAT data format

5,378 views
Skip to first unread message

Putrisia Hendra

unread,
Aug 4, 2010, 11:26:04 PM8/4/10
to
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

Putrisia Hendra

unread,
Aug 4, 2010, 11:50:21 PM8/4/10
to

Putrisia Hendra

unread,
Aug 4, 2010, 11:51:04 PM8/4/10
to
any one can help me do this????

TideMan

unread,
Aug 5, 2010, 12:15:37 AM8/5/10
to
On Aug 5, 3:51 pm, "Putrisia Hendra " <putrisiaza...@gmail.com> wrote:
> any one  can help me do this????

Have you read the data from the .txt file into Matlab yet?
If so, you can write them to a .mat file using save:
save('MyEEGData')
and retrieve them using load:
load('MyEEGData')

Walter Roberson

unread,
Aug 5, 2010, 12:29:23 AM8/5/10
to

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.

Putrisia Hendra

unread,
Aug 5, 2010, 4:04:09 AM8/5/10
to
"Putrisia Hendra " <putris...@gmail.com> wrote in message <i3dcf8$ip$1...@fred.mathworks.com>...

> any one can help me do this????

i have try it..
it's done..!


Thank You so Much..

ayalew...@gmail.com

unread,
Dec 10, 2012, 4:01:38 AM12/10/12
to Putrisia Hendra

gork...@gmail.com

unread,
Dec 25, 2012, 8:19:48 PM12/25/12
to Putrisia Hendra

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.

gork...@gmail.com

unread,
Dec 25, 2012, 8:29:33 PM12/25/12
to Putrisia Hendra
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.

dpb

unread,
Dec 25, 2012, 8:47:15 PM12/25/12
to
On 12/25/2012 7:29 PM, gork...@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?

--

gork...@gmail.com

unread,
Dec 26, 2012, 12:22:08 AM12/26/12
to

> 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

TideMan

unread,
Dec 26, 2012, 3:00:25 PM12/26/12
to
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.

gork...@gmail.com

unread,
Dec 26, 2012, 5:20:43 PM12/26/12
to
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.

dpb

unread,
Dec 26, 2012, 5:53:15 PM12/26/12
to
On 12/26/2012 4:20 PM, gork...@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...

--

msdar...@gmail.com

unread,
Feb 27, 2013, 10:03:06 AM2/27/13
to Putrisia Hendra
On Thursday, August 5, 2010 12:51:04 AM UTC-3, Putrisia Hendra wrote:
> any one can help me do this????

Dear Putrisia,

I agree with TideMan suggestion, but an easier way to convert them into MAT-files in MATLAB is to convert tthem by the tool associated in the software.
For this reason, go to "workspace panel", click Open, then you will see a window asking about creating a MAT-File or no? in this window, upload your TXT file from your computer, then proceed to the Next option, finally the MAT-File will be created for you.
Any doubts please feel free to write for me.

Bests
Mostafa

2011...@smvdu.ac.in

unread,
Oct 25, 2014, 1:55:55 PM10/25/14
to
yes you can..

try this

s=fopen('file_nam.tax','r');
val=fscanf(s,'%f');
fclose(s);
save('mat_file_nam.mat','val');

shaswati...@gmail.com

unread,
Sep 13, 2017, 3:24:04 AM9/13/17
to
i have the same query....can anybody help me out of this?

dpb

unread,
Sep 13, 2017, 8:47:30 AM9/13/17
to
Read the text file into variable, SAVE the variable. Done.

--

dpb

unread,
Sep 13, 2017, 1:12:19 PM9/13/17
to
On 13-Sep-17 2:23 AM, shaswati...@gmail.com wrote:
> On Thursday, August 5, 2010 at 8:56:04 AM UTC+5:30, Putrisia Hendra wrote:
...

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

Which, of course, will only save time overall if you read the resulting
file multiple times after creating the .mat-file version of it.

The better solution if possible would be to create the file as .mat or
stream from the original application; not all external programs will
have that capability but many do.

--

0 new messages