我如何将matlab答案导出到excel?

我在Matlab中做了简单的计算器GUI。 如何导出每个答案在MATLAB中的excel? 请帮助我..我已经使用xlswrite,但它只会取代Excel中的答案..你能帮我一个代码,导出每个答案,以不断增加答案

代码示例:

a = get(handles.input1_gamma,'String'); %gamma b = get(handles.input2_h,'String'); %hc = get(handles.input3_q,'String'); %qd = get(handles.input4_power,'String'); %POWER % a and b are variables of Strings type, and need to be converted % to variables of Number type before they can be added together out = [str2num(a) * str2num(b)* str2num(c)]; e = {'Power','gamma','H','Q'; out,str2num(a),str2num(b),str2num(c)}; xlswrite('results.xls', e, 'Sheet1' , 'A1'); 

我想你想要在你的代码中定义的functin xlswrite('results.xls',e,'Sheet1','A1');

来自德国的Frohe Weihnachten

也可以看看:

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

我的build议:

 function [ output_args ] = xlswrite( file , e , sheet,range) %XLSWRITE Summary of this function goes here % Detailed explanation goes here %open excel file with absolute path file =[cd '\' file]; exlObject = actxserver('Excel.Application'); exlObject.visible = 1; exlObject.Workbooks.Open(file); exlWkbk = exlObject.Workbooks; %save e to defined range exlSheet1=exlObject.Sheets.Item(sheet); dat_range=[range ':' range]; rngObj = exlSheet1.Range(dat_range); rngObj.Value=e; %save and close exlObject.DisplayAlerts=0; exlSheet1.SaveAs(file); exlWkbk.Close; exlObject.Quit; 

您可以使用xlsappend将您的函数的输出导出到Excel,在xlsappend 站点上可用。

xlsappend将通过检测Excel工作表的第一个未使用的行来附加数据,并粘贴数字(或单元格)数组。

 [success,message] = xlsappend(file,data,sheet)