文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > matlab导出数据到xls
侵权投诉

matlab导出数据到xls

matlab如何导出数据到excel文件,数学建模常用

提示:对于Matlab7.0或2007版本以下才需要将本函数编写为M函数放在工作路径之下,进行调用,对于高版本
Matlab已自带本函数,可以直接调用,函数名相同,具体调用方式见help xlswrite。
function xlswrite(m,header,colnames,filename);
% xlswrite Easily create an Excel spreadsheet from MATLAB
%
% xlswrite(m,header,colnames,filename) creates a Microsoft Excel
% spreadsheet using
% the MATLAB ActiveX interface. Microsoft Excel is required.
%
%Inputs:
% m Matrix to write to file
% (Optional):
% header String of header information.
% Use cell array for multiple lines
% DO NOT USE multiple row character arrays!!
% colnames (Cell array of strings) Column headers.
% One cell element per column
% filename (string) Name of Excel file. If not specified, contents will


% be opened in Excel.
%
% ex:
% m = rand(100,4);
% header = 'my data';
% %header{1} = 'first line'; %This will give
% %header{2} = 'second line'; % 2 header lines
% colnames = {'Ch1','Ch2','Ch3','Ch4'};
%
% xlswrite(m,header,colnames,'myfile.xls');
% will save the spreadsheet as myfile.xls. The user
% will never see Excel
% xlswrite(m,header,colnames);
% will open Excel with these contents in a new spreadsheet.
%




% Scott Hirsch
% The MathWorks
% This is provided free, no warranty, ...


% Copied from ActiveX example in documentation


[nr,nc] = size(m);
if nc>256
error('Matrix is too large. Excel only supports 256 columns');
end;


% Open Excel, add workbook, change active worksheet,
% get/put array, save.
% First, open an Excel Server.
Excel = actxserver('Excel.Application');




%If the user does not specify a filename, we'll make Excel visible
%If they do, we'll just save the file and quit Excel without ever making
% it visible
if nargin<4
set(Excel, 'Visible', 1); %You might want to hide this if
% you autosave the file
end;


% Insert a new workbook.
Workbooks = Excel.Workbooks;
Workbook = invoke(Workbooks, 'Add');


% Make the first sheet active.
Sheets = Excel.ActiveWorkBook.Sheets;
sheet1 = get(Sheets, 'Item', 1);
invoke(sheet1, 'Activate');


% Get a handle to the active sheet.
Activesheet = Excel.Activesheet;


%Write header
if nargin<2 | isempty(header)
nhr=0;
elseif iscell(header)
nhr = length(header); %Number header rows
for ii=1:nhr
ActivesheetRange = get(Activesheet,'Range',...
['A' num2str(ii)],['A' num2str(ii)]);
set(ActivesheetRange, 'Value', header{ii});
end;
else
nhr = 1; %Number header rows
ActivesheetRange = get(Activesheet,'Range','A1','A1');
set(ActivesheetRange, 'Value'

第1页

你可能喜欢

热门文档

相关文档

  • matlab数据导出到excel

    matlab数据导出到excel_理学_高等教育_教育专区。matlab数据导出到excel你可以直接在m文件里面用xlswrite函数:(filename/sheet/range都是要加单引号滴) xlswrite(...

  • matlab导出数据(fprintf,dlmwrite,xlswrite)

    matlab导出数据(fprintf,dlmwrite,xlswrite)_电脑基础知识_IT/计算机_专业资料...在图像数组的输出到文件的操作上,我发现 fprintf 比 dlmwrite 明显 快很多,但...

  • matlab与excel数据导入导出

    matlab与excel数据导入导出_计算机软件及应用_IT/计算机_专业资料。相互切换无...可以利用数据导入向导把 Excel 文件中的数据导入到 MATLAB 工作空间,步骤与 6....

  • matlab导出数据的方法讲义

    matlab导出数据的方法讲义_理学_高等教育_教育专区。如何用matlab导出数据matlab 导出数据(fprintf,dlmwrite,xlswrite 函数) 1.用 fprintf 函数写数据到 txt,xls ...

  • matlab数据导入和导出

    matlab数据导入和导出_工学_高等教育_教育专区。MATLAB导入文本文件 文本文件需要... 'E1')将单元格数组 d 的数据写出至 tempdata.xls 文件,新建工作表'...

  • Matlab中数据的导入与导出

    Matlab 中数据的导入与导出 把 excel 中的数据导入 matlab 中的矩阵 a a=xlsread(‘路径\文件名.xls’,sheet,’数据段’) 把 matlab 中的矩阵 b 导出到 ...

  • 将MATLAB数据保存到Excel中的程序

    将MATLAB数据保存到Excel中的程序_理学_高等教育_教育专区。将MATLAB数据保存到... matlab数据导入和导出 3页 免费 matlab与excel xlsread、... 4页 1下载券...

  • matlab中的数据导入和导出

    matlab中的数据导入和导出_IT/计算机_专业资料。matlab 中的数据导入和导出 ... 'E1')将单元格数组 d 的数据写出至 tempdata.xls 文件,新建工作表'...

  • Matlab数据的导入与导出

    Matlab数据的导入与导出_计算机软件及应用_IT/...从Excel文件中读取数据 把数据写入Excel文件 2013-7...数据 明 从文本文件导入数据到 MATLAB 工 打开文件...

  • Matlab数据导入导出方法

    Matlab数据导入导出方法_计算机软件及应用_IT/计算机...('filename'),将 filename 中的数据导入到工作区...文件、word 文件、xml 文件、xls 文件、图像文件和...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email