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

标签 excel matlab automation

我在 Matlab 中制作了简单的计算器 GUI。如何将每个答案导出到 MATLAB 中的 excel?请帮帮我..我已经使用过xlswrite,但它只会替换excel中的答案..你能帮我一个将每个答案导出到excel的代码吗?

代码示例:

a = get(handles.input1_gamma,'String'); %gamma 
b = get(handles.input2_h,'String'); %h 
c = get(handles.input3_q,'String'); %q 
d = 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');

最佳答案

我猜您想要代码中定义的函数 xlswrite('results.xls', e, 'Sheet1' , 'A1');

来自德国的 Frohe Weihnachten

也可以看看:

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

我的建议:

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;

关于excel - 如何将matlab答案导出到excel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8583932/

相关文章:

vba - 在组合框和列表框上为 ListFillRange 使用表格列

matlab - 在 MATLAB 中,如何在散点图中使用带有颜色图的图例

matlab - 测试表 Matlab 中是否存在列

math - 自定义轴刻度 - "Reverse"对数?

javascript - 如何在 iMacros 下仅用条件替换字符串的特定部分

.net - 提高 MS Excel 写入性能

vba - 参数数量错误或属性分配无效

excel - 导入包含多行单元格的制表符分隔文本文件(到 Excel 或 Access)

python - 在 Python 中使用 xlrd 将数字 Excel 数据读取为文本

linux - 有关在文章/Web 2.0 网站上创建帐户/发帖的自动化过程的帮助