%% Write Matrix to Specified Sheet and Range
% Create a matrix and write it to a specified sheet and range in a spreadsheet file.
% Create a matrix in the workspace.

M = magic(5)

% Write the matrix to M.xls, to the second worksheet in the file, starting at the third row.

writematrix(M,'M.xls','Sheet',2,'Range','A3:E8')

% Read and display the matrix.

readmatrix('M.xls','Sheet',2,'Range','A3:E8')

% Copyright 2018 The MathWorks, Inc.