Exporting a 50 by 50 Matrix to excel
2 views (last 30 days)
Show older comments
hello I was wondering How I can Export a 50x50 matrix to excel.
I found that I can use xlswrite, but I have to assign a range, which is kind of confusing, Because I have to specify the range.
Is there a way I can just give the matrix as an input argument and get the matrix, without specifying the range ?
Answers (2)
the cyclist
on 14 Dec 2011
The range is an optional argument to xlswrite(). It will just start at A1 if you don't specify the range.
You can also just specify the first cell of the range, and the extent will be determined by the size of the matrix.
2 Comments
Image Analyst
on 14 Dec 2011
No. If you would look in the help you'll see how to do it plus this example:
Write mixed text and numeric data to testdata2.xls, starting at cell E1 of Sheet1:
d = {'Time','Temperature'; 12,98; 13,99; 14,97};
xlswrite('testdata2.xls', d, 1, 'E1')
d could be a numerical matrix instead of a cell array and it would still work.
Aldin
on 15 Dec 2011
Here is the code of your problem:
if you have : mat = [ 1 2 3; 4 5 6; 7 8 9 ; 10 11 12 13];
leng = length(mat); % leng = 4
for i = 1:leng
var = ['A',num2str(i)];
xlswrite('data.xls',x(i,:),1,var);
end
Thats it
x(1,:) ----> 1 2 3 x(2,:) ----> 4 5 6 x(3,:) ----> 7 8 9 with for loop and so on...
var ---> A1,A2,A3.... with for loop
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!