MATLAB: Convert a matrix in the workspace into Excel in GUI

excel

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?

Best Answer

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.
Related Question