使用matlab将100个文本文件保存到一个Excel文件,但不同的电子表格?

嗨,我有一个大约50到100个文本文件,我想将其数据放入不同的电子表格。 所有的文件都有两行文本,Thord行在后面以数字和文本开头。 其余的就像1000 x 500 int。 我想在matlab中做到这一点。

请,任何build议?

如果您在Windows下运行MATALB,则可以使用COM自动化来控制Excel并创build必要的文件。

以Mathworks文件交换中的xlswrite为例。

引用的代码不会创build新的Excel工作表,但可以填充您事先创build的任何现有工作表(当然是在现有的工作簿中)。

如果filename是要打开的文件,则下面的代码(基于xlswrite)可能会有所帮助:

 Excel = actxserver('Excel.Application'); op = invoke(Excel.Workbooks, 'open', [pwd filesep filename]); set(Excel, 'Visible', visible); % you may safely remove this cell_update(sheetname, row, col, value) function cell_update(sheetname, row, col, value) % Make the specified sheet active. try Sheets = Excel.ActiveWorkBook.Sheets; target_sheet = get(Sheets, 'Item', sheetname); catch % Error if the sheet doesn't exist. It would be nice to create it, but % I'm too lazy. % The alternative to try/catch is to call xlsfinfo to see if the sheet exists, but % that's really slow. error(['Sheet ' sheetname ' does not exist!']); end; invoke(target_sheet, 'Activate'); Activesheet = Excel.Activesheet; cellnum = [num2col(col) num2str(row)]; ActivesheetRange = get(Activesheet,'Range', cellnum, cellnum); set(ActivesheetRange, 'Value', value); end