Define filname for exported data with GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi guys,
I would like to define the name of an exported xls file via GUI, so I added the following commands to a "filename_callback":
contents=cellstr(get(hObject,'String'));
filename=[contents{get(hObject,'String')}];
assignin('base','filename',contents);
in the next step I use the following command to save my Matrix "results":
save('results','filename','xls');
The Excel-file should have the name, that I add in GUI, but I'm always receiving the error: Error using save Variable 'filename' not found.
Does anybody have an advice?
댓글 수: 0
채택된 답변
Ingrid
2015년 12월 21일
the save command saves the data in .mat format by default. It is not possible to write to xls format with this command, only to ascii if specified by the options. What you are probably looking for is xlswrite
xlswrite(filename,results)
댓글 수: 2
Ingrid
2015년 12월 22일
why not just use
filename = get(hObject,'String');
before calling
xlswrite(filename,results)
I do not see why you want to assign the variable to your base workspace as this is not necessary
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!