creat a excel file from matlab

Asked by Cordelle about 12 hours ago
Latest activity Commented on by Evan about 11 hours ago

I have data that I want to put in a excel file from matlab. the data is coming from a text file that I read in using textscan, here is my sample code:

fileID = fopen('passReport.EO1_2013_107_193146');

c = textscan(fileID, '%s')

fclose(fileID);

data = celldisp(c);

I want to take the data in the variable "data" and create a excel file with it

0 Comments

Cordelle

Products

1 Answer

Answer by Evan about 12 hours ago
Edited by Evan about 12 hours ago

The "xlswrite" command should do what you need:

help xlswrite

xlswrite allows you to control the file to which your data is written, the sheet within that file to which your data is written, and the specific cells to which your data is written. If a file with the name you provide does not already exist, a new one is created. Very handy function.

3 Comments

Cordelle about 11 hours ago

when i tried to use the xlswrite function, an error message occured:

Error using celldisp

Too many output arguments.

Error in Untitled (line 11)

xlswrite(filename, A)

this is the code i used:

fileID = fopen('passReport.EO1_2013_107_193146');

c = textscan(fileID, '%s')

fclose(fileID);

A = celldisp(c)

filename = 'EO1_2013_107_193146.xlsx';

xlswrite(filename, A)

Cordelle about 11 hours ago

Do you know How i could get the data from passReport.EO1_2013_107_193146 to a excel file that I would name, EO1_2013_107_193146.xlsx using matlab code

Evan about 11 hours ago

Your error looks to be coming not from the xlswrite call, but from the celldisp call. celldisp does not operate with an output meaning A = celldisp will not work.

Is there any reason that you cannot simply write c directly to your excel file, like so?

    xlswrite(filename, c)

If you cannot, for example because the textscan call is not returning the data in the form you want, you will need to make some changes to the way the data is organized, but I don't think celldisp would be the way to do it.

Evan

Contact us