Hi, I am reading in an excel file using the command: [A, headertext] = xlsread('File.xls') My numeric values are in A and column names saved in headertext. Now I make my changes and I am trying to use xlswrite to write out the file. My question is, how to incorporate the same column names in headertext while writing out a new excel file? Thanks Suman
You'll need to make a cell array containing the string/headers and the numeric data, similar to Example 2 in the doc for xlswrite. So something like, [A, headertext] = xlsread('File.xls'); newA = ..... outputMatrix = cell(1+size(newA,1),size(newA,2)); outputMatrix(1,:) = headertext; outputMatrix(2:end,:) = num2cell(newA); xlswrite('newfilename.xls',outputMatrix); I'm assuming here that newA and headertext have the same number of columns. Phil.
Thanks for the tip Phil. It sure works. "Phil Goddard" <philgoddardNOSPAM@telus.net> wrote in message <g7ini9$rbh$1@fred.mathworks.com>... > > You'll need to make a cell array containing the > string/headers and the numeric data, similar to Example 2 > in the doc for xlswrite. > So something like, > > [A, headertext] = xlsread('File.xls'); > newA = ..... > outputMatrix = cell(1+size(newA,1),size(newA,2)); > outputMatrix(1,:) = headertext; > outputMatrix(2:end,:) = num2cell(newA); > xlswrite('newfilename.xls',outputMatrix); > > I'm assuming here that newA and headertext have the same > number of columns. > > Phil. > >