MATLAB: How to export to excel

excelmacMATLAB

Hi everyone, I just installed excel(2016) in my Mac so I tried the below code just then it shows the following error.
ans =
1.6629028619989176615049162203409
xlswrite('a.xls','ans')
Warning: Could not start Excel server for export. XLSWRITE will attempt to write file in CSV format.

Best Answer

That's normal for a Mac. Also, you'll probably see a in one cell, n in the next cell to the right, and s in the next cell to the right. If you want the string 'ans' to go in as a string into one cell, put it in braces:
xlswrite('a.xlsx', {'ans'})
If you want the number 1.662 to go in, use ans without quotes
xlswrite('a.xlsx', ans)