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

how to convert a .txt file into a .xls file in matlab?

Asked by Cordelle on 18 Jun 2013

I suspect that I can actually read the log file data directly into Matlab without conversion. It is just a comma separated variable format(.csv), I believe, and I think it should be accessible to some Matlab input routine.

However,I dont not know the matlab input routine; It would be very helpful if someone can enlighten me on the input routine

thanks in advance, Cordelle

0 Comments

Cordelle

Products

No products are associated with this question.

2 Answers

Answer by Jan Simon on 18 Jun 2013

This is not enough information to give a more explicit answer than:

  • Import the file by e.g. importdata or fopen / fscanf.
  • Export the data by xlswrite.

I suggest to add mire details, e.g. the file's contents by editing the original question (not as comment or answer).

2 Comments

Cordelle on 18 Jun 2013

When I imported the file using importdata this occured:

data: 3

    textdata: {863x4 cell}

what does this mean? and how can I convert the imported file into an excel file?

Iain on 18 Jun 2013

That means that data is a structure containg the field "textdata", and that "textdata" contains a cell array (each element of a cell array can be a different type of number, string, or even another array).

Try:

 xlswrite('myxl.xls',data.textdata)
 winopen('myxl.xls')
Jan Simon
Answer by Shashank on 18 Jun 2013

That means its a cell in a structure.

You can access data from structures:

http://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-structure-array.html

and use

http://www.mathworks.com/help/matlab/ref/xlswrite.html

If you need editing in between you should do that.

If you are unfamiliar with cell and structures at all in MATLAB, I point you to

http://www.mathworks.com/help/matlab/getting-started-with-matlab.html

3 Comments

Cordelle on 18 Jun 2013

Error using load

Number of columns on line 3 of ASCII file

\\dc1nas\Projects-AB\AS\Jobs\Jobs-2012\1538_KSAT_SG24\40_Testin\03_Test_Report\SAT\SAT_Demo_Passes\passReport.TERRA_2013_107_165606

must be the same as previous lines.

How can i correct this issue? (I used the "Load" input routine)

Jan Simon on 18 Jun 2013

Please do not post explanations like "I used the "Load" input routine", but the corresponding code. This will reduce misunderstandings. Thanks.

Shashank

Contact us