export from matlab to excel
Show older comments
sir help me about the commad how can i export my result in to the excel file.
Answers (3)
You can use writematrix or xlswrite.
Please see following URL.
R2019a or later : writematrix
example code
M = magic(5)
writematrix(M,'M.xlsx','Sheet',2,'Range','A3:E8')
R2018b or earlier : xlswrite
exanple code
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
xlswrite(filename,A)
1 Comment
Chaudhary P Patel
on 1 Feb 2020
Chaudhary P Patel
on 1 Feb 2020
7 Comments
stozaki
on 1 Feb 2020
What OS platform do you use? Win10, Mac OS or Linux?
Chaudhary P Patel
on 1 Feb 2020
Chaudhary P Patel
on 1 Feb 2020
stozaki
on 1 Feb 2020
I tested following script in the R2018a.
I was able to write the data to the excel file without any problems.
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
xlswrite(filename,A)
I attach it as a .gif.

Chaudhary P Patel
on 1 Feb 2020
Image Analyst
on 1 Feb 2020
Are you 100% sure you have Excel installed? Perhaps that might cause a problem.
If you don't have Excel on that computer, use csvwrite() to write a CSV file, which can be opened by WordPad.
Why are you not upgrading to R2019b, where you can get writecell()? It's much, much faster in my experience than xlswrite().
Chaudhary P Patel
on 2 Feb 2020
0 votes
15 Comments
Do you run the following test script and open actxserver?
If you get error message, please tell me the error message.
try
Excel = actxserver('excel.application');
fprintf('>> excel server open. \n');
catch ME
fprintf('>> %s. \n',ME.message);
end
Excel.Quit;
Excel.delete;
fprintf('>> excel server close. \n');
Chaudhary P Patel
on 2 Feb 2020
stozaki
on 2 Feb 2020
Pleae run this command independently. Just the script to test your environment.
Chaudhary P Patel
on 2 Feb 2020
Edited: Chaudhary P Patel
on 2 Feb 2020
stozaki
on 2 Feb 2020
I am very sorry. My script had a miss spelling. I have modified it. Please re-try it. If you have caught an error, matlab didn’t have connect excel. Could you login your PC as administrator and try it?
Chaudhary P Patel
on 2 Feb 2020
stozaki
on 2 Feb 2020
Could you login your PC as administrator and try it? I have experienced the problem of access when Excel is installed but not registered.
Walter Roberson
on 2 Feb 2020
Excel is not installed on your system, or is not properly installed, or else you have a quite old version of Excel that is 32 bit only but you are using a 64 bit MATLAB
Chaudhary P Patel
on 3 Feb 2020
Walter Roberson
on 3 Feb 2020
If everything was okay related to excel then the activex test would have succeeded.
Chaudhary P Patel
on 3 Feb 2020
Walter Roberson
on 3 Feb 2020
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
T = array2table(A);
writetable(T, filename, 'WriteVariableNames', false);
You might possibly get a warning message about having trouble connecting to Excel, but it should then use the built-in routines that do not use Excel .
Starting in the release after yours, R2018b, it is possible to add an option 'UseExcel', false to cause it to deliberately skip even attempting to use Excel.
Chaudhary P Patel
on 3 Feb 2020
Walter Roberson
on 3 Feb 2020
To open it in MATLAB use readtable() not xlsread()
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!