How can I add a new row of results in excel every time when I click the push button in GUI?
6 次查看(过去 30 天)
显示 更早的评论
I am new to Matlab, been trying to write a program to simulate fluid dynamics, the codes seem working fine, however I am struggling with how to export the results to excel. To make it easier to understand, here is a simple example of what I want to do. Assuming I have 2 input variables (a and b) and 3 output variables (c,d and e), where c=a+b, d=a*b, e=a/b. I can type in any number I want in boxes a and b, then press the push button, the program will tell me the values of c, d and e. Below are the m file:
function pushbutton1_Callback(hObject, eventdata, handles)
c=str2num(get(handles.a,'string'))+str2num(get(handles.b,'string'))
set(handles.c,'string',c)
d=str2num(get(handles.a,'string'))*str2num(get(handles.b,'string'))
set(handles.d,'string',d)
e=str2num(get(handles.a,'string'))/str2num(get(handles.b,'string'))
set(handles.e,'string',e)
m=[str2num(get(handles.a,'string')) str2num(get(handles.b,'string')) c d e]
filename= 'testdata.xlsx';
xlswrite(filename,m)
However, it seems Matlab simply overwrites the old spreadsheet every time when I press the push button, what I really want for Matlab is to add another row of data below the existing one every time when I press the button. Can anyone help me with that? Thanks in advance!
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!