How to store a number of arrays in excel file?

조회 수: 2 (최근 30일)
nl2605
nl2605 2013년 7월 19일
Hallo Everyone
I am writing data into an excel file. However, the range of the data to be stored keeps changing and I want to change the range in the xlswrite command accordingly. Any ideas what can be done?
For example:
A=data1; % 1 by 12 matrix(present). However, data1 is a matrix whose rows and column numbers keep on changing
xlswrite(filename,A,'sheet1','A1:A12');
I want to change this range 'A1:A12' as the data1 keeps changing.
Thanks a lot.

채택된 답변

Vishal Rane
Vishal Rane 2013년 7월 19일
편집: Vishal Rane 2013년 7월 19일
Dim = size(data1); % output is [ m, n]
Range = ['A1:',strrep([char(64+floor(Dim(2)/26)),char(64+rem(Dim(2),26))],'@',''),num2str(Dim(1))] % Range required for data1
xlswrite( filename, data1, 'sheet1', Range);
You will have to put a check for upper and lower limit since excel 10 supports 256 cols and 65536 rows only.
  댓글 수: 2
Jan
Jan 2013년 7월 19일
편집: Jan 2013년 7월 19일
char(64+Dim(2)) is a very bad idea. E.g. what happens if Dim(2) is 65 ?!
Vishal Rane
Vishal Rane 2013년 7월 19일
편집: Vishal Rane 2013년 7월 19일
oops ! evidently i did'nt think that through !
Answer updated !

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

nl2605
nl2605 2013년 7월 19일
I used sprintf instead. And its working too. Thanks a lot. Also, isn't there any other method by which we can write all the data being generated into an excel file without worrying about the dimensions?

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by