creat a excel file from matlab

64 ビュー (過去 30 日間)
Cordelle
Cordelle 2013 年 7 月 1 日
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

採用された回答

Evan
Evan 2013 年 7 月 1 日
編集済み: Evan 2013 年 7 月 1 日
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.
  14 件のコメント
Evan
Evan 2013 年 7 月 2 日
編集済み: Evan 2013 年 7 月 2 日
The row/column limit for recent versions of excel is much higher than 852 rows, so I don't think excel would be the cause of your problem. Also, I had no trouble writing a random cell array of size 1000x200 to an excel file using xlswrite, so I don't think xlswrite would be the culprit. It sounds like it has something to do with your text file or the way you're reading it in, but I really can't say for sure.
Evan
Evan 2013 年 7 月 3 日
Oops, it looks like I either missed your last comment or we both posted at around the same time. Glad you have it working!

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 7 月 2 日
You can't send c into xlswrite or else it will put one character per Excel cell. You have to put the string into a cell first.
fileID = fopen('passReport.EO1_2013_107_193146');
c = textscan(fileID, '%s')
fclose(fileID);
caC = {c}; % Stick string into a single cell.
xlswrite(XLFileName, caC, 'A1');
  1 件のコメント
Cordelle
Cordelle 2013 年 7 月 2 日
編集済み: Cordelle 2013 年 7 月 2 日
Thanks for the help, but a error message still occurred:
Error using xlswrite (line 220)
Error: Object returned error code: 0x800A03EC
Error in Untitled (line 14)
xlswrite(filename, caC, 'A1');
the data in the file is numeric data, do you think its not transferring to the excel file because we are trying to read a string?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by