The following examples illustrate how to use XLSWRITE to add column and row labels to a MATLAB matrix that is written to an Excel file. This can be done either by writing to several sections of the worksheet (Case 1), or by joining the data and labels before writing to the XLS-file (Case 2).
Case 1. Using several XLSWRITE commands:
data=ones(10,4);
col_header={'Temperature','Pressure','X','Y'};
row_header(1:10,1)={'Time'};
xlswrite('My_file.xls',data,'Sheet1','B2');
xlswrite('My_file.xls',col_header,'Sheet1','B1');
xlswrite('My_file.xls',row_header,'Sheet1','A2');
Case 2. Using one XLSWRITE command:
data=ones(10,4);
data_cells=num2cell(data);
col_header={'Temperature','Pressure','X','Y'};
row_header(1:10,1)={'Time'};
output_matrix=[{' '} col_header; row_header data_cells];
xlswrite('My_file.xls',output_matrix);
Best Answer