Search code examples
excelmatlabexport-to-excel

MATLAB:How to write in the empty rows in Excel


I have two arrays in MATLAB and i want to import them to excel

A=[1,2,3,6,7,9]
B=[5,6,7,8,9,0]

Im using this command to write in excel

xlswrite('name',A,'','A1:F1')

I want to write the first Array (A) in row 1 in excel, I would like to write Array B in the next empty row. Sometimes i have alot of arrays that i need to export to excel and it dosent make any sense to use xlswrite and to change the range every single time i execute the code!

Any ideas?

Many thanks in advance


Solution

  • If your MATLAB version is older than R2019a, use:

    >> xlswrite('name',[a;b],'','A1:F2')
    

    Otherwise, use the recommended writematrix:

    >> writematrix([a;b],'name.xls')