MATLAB: How to speed-up the ”write, read and save” of an excel file from matlab

matlab excel read write save

I want to write on an excel file, run a VBA macro, save the excel file and finally read from the file, several times. I used below code, but it is very time-consuming. The question is how can I speed up the above commands? xlswrite usually takes: 11 sec., open: 1 sec., Run: 10 sec., save: 20 sec. and xlsread: 2 sec. It should be mentioned that I don't need to save the file but if I don't save, the command xlsread doesn't read the newly-changed cells values!
xlswrite ('C:\test.xls',M ,'sheet_name_1','T10:T16');
excelObject = actxserver('Excel.Application');
excelObject.Workbooks.Open('C:\test.xls');
excelObject.Run('VBAMacro');
excelObject.WorkBooks.Item('test.xls').Save;
excelObject.WorkBooks.Item('test.xls').Close;
CC = xlsread ('C:\test.xls','sheet_name_2','E:E');

Best Answer

use ActiveX to write and read instead of xlswrite and xlsread respectively.