From: seshadri baral on
i want to insert a matrix to a excel file from matlab. The problem is
i dont know the range of cells to be used beforehand. There are
various sized matrixes and i have to give cell ranges for all. If my
matrix size is 20X366,it is difficult to calculate the cell range and
give it at the prompt. Is there any easier solution ,so that i could
write the variables with minimum effort.
the code for 'write_to_excel.mat' is as follows

function [status,message]= write_to_excel(varargin)

count=nargin;
for i= 1:count
file_name=input('Please give the filename to store the result');
sheet_name=input('Please give the sheet name');
size_of_variable=size(varargin{i});
disp(size_of_variable)
var=varargin{i};
column_range=input('Please give the column range(according to above
row column size');
[status,message]=xlswrite(file_name,var,sheet_name,column_range);
end
end
From: Thomas Britton on
Are you writing more than 1 matrix per sheet? If so how will you deal with them?

xlswrite takes one cell as input and will populate the neighbours accordingly without any extra effort (just put in the top left cell).

If you are rewriting subsequent data to the sheet, think about how you want it to turn out. Then you could use an xlsread command to find out what is there already (use the raw output and perform a size cmd) then you can work out the next 'free' cell by again using a size command and use that as your input to the imwrite command.


seshadri baral <chotturock(a)gmail.com> wrote in message <e521ebd0-7bc1-4af4-b48b-81394324eb97(a)s22g2000prd.googlegroups.com>...
> i want to insert a matrix to a excel file from matlab. The problem is
> i dont know the range of cells to be used beforehand. There are
> various sized matrixes and i have to give cell ranges for all. If my
> matrix size is 20X366,it is difficult to calculate the cell range and
> give it at the prompt. Is there any easier solution ,so that i could
> write the variables with minimum effort.
> the code for 'write_to_excel.mat' is as follows
>
> function [status,message]= write_to_excel(varargin)
>
> count=nargin;
> for i= 1:count
> file_name=input('Please give the filename to store the result');
> sheet_name=input('Please give the sheet name');
> size_of_variable=size(varargin{i});
> disp(size_of_variable)
> var=varargin{i};
> column_range=input('Please give the column range(according to above
> row column size');
> [status,message]=xlswrite(file_name,var,sheet_name,column_range);
> end
> end
 | 
Pages: 1
Prev: Optical OFDM
Next: Matrix comparison ...