f



Excel In Matlab

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
0
8/8/2008 6:24:01 PM
comp.soft-sys.matlab 211266 articles. 14 followers. lunamoonmoon (258) is leader. Post Follow

2 Replies
385 Views

Similar Articles

[PageSpeed] 26

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.


0
8/9/2008 12:15:06 AM
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.
> 
> 

0
8/11/2008 5:02:01 PM
Reply: