Convert a matrix in the workspace into Excel in GUI

조회 수: 1 (최근 30일)
Arif
Arif 2011년 10월 19일
I have a matrix A of size(n*m) in the workspace. I would like to develop a GUI which has a push button. So whenever I click on it, the matrix A which is present in the workspace convert it into Excel file. So that I can save it easily as Excel file.
Could you please suggest me the code for this?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 10월 19일
You just need to run xlswrite. For example,
xlswrite('test.xls',rand(3,4))
Inside your push button callback, you might need to run this:
xlswrite('test.xls',evalin('base','MatrixA')) where 'MatrixA' is your variable name.
  댓글 수: 2
Arif
Arif 2011년 10월 19일
Thanks for your reply.But I want to select my Matrix A from work space whenever I use push button.
Problem is I would like to write a code so whenever I click the push button present on the GUI so first it allows me to choose the required matrix then I have a piece of code which manipulate matrix according to my wish and then save it in excel.
So I would like to choose the matrix in run time process.
Thanks
-Arif
Fangjun Jiang
Fangjun Jiang 2011년 10월 19일
That can be done too. The function who() or whos() can give you a list of variables and their properties. Once you have that list, you can put the list in a ListBox or Popup Menu. Then you can let the user to select the variable name. Once you get the variable name, then the above xlswrite() line can get the job done. Start from here to see some GUI examples.
http://www.mathworks.com/help/techdoc/creating_guis/exampleindex.html

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 10월 19일
Well I would recommend looking at:
guide
to develop your GUI, and xlswrite to develop your excel export.
  댓글 수: 1
Arif
Arif 2011년 10월 19일
Thanks for your reply.Actually I would like to select the required matrix A and there are other matrix also.And whenever I use xlswrite I need to write Matrix name again and again.
Problem is I would like to write a code so whenever I click the push button present on the GUI so first it allows me to choose the required matrix then I have a piece of code which manipulate matrix according to my wish and then save it in excel.
So I would like to choose the matrix in run time process.
Thanks
Arif

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by