Variable index in excel write

조회 수: 1 (최근 30일)
mayank agrawal
mayank agrawal 2015년 11월 23일
댓글: mayank agrawal 2015년 11월 23일
rating=[1,2,3,4,5,6];
fullFilepathScene=[];
header={'Scene','Mean','Variance','Entropy','Percentage Pixels','ACM','ISE'}
xlswrite('rating',header,'Ratings');
num = xlsread('rating.xls','Ratings')
[index,n]=size(data)
index=index+1
index=(num2str(index));
index=strcat('A',index)
xlswrite('rating',{fullFilepathScene,rating(1),rating(2),rating(3),rating(4),rating(5),rating(6)},'Ratings',index);
The problem is it is writing on the same index.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 11월 23일
The only thing you write to the file the first time is the header. Then you use the form of xlsread() that only reads the numeric portion of the data. There is no numeric portion, so num comes out empty, of size 0. You increment that 0 to 1, and so calculate that you want to write in A1 -- which is where the header is.
When you use
num = xlsread(...)
then the data read in from the file is stripped of all leading rows that are come out as completely NaN as numbers, and is stripped of all leading columns that come out as completely NaN as numbers, and is stripped of all trailing columns that come out as completely NaN as numbers. When all there is in the file is the header, that leaves nothing to read.
You should use
[num, txt, raw] = xlsread('rating.xls','Ratings');
[numrows, n] = size(raw);
index = sprintf('A%d', numrows+1);
xlswrite('rating',{fullFilepathScene, rating(1), rating(2), rating(3), rating(4), rating(5), rating(6)}, 'Ratings', index);
  댓글 수: 1
mayank agrawal
mayank agrawal 2015년 11월 23일
Thanks for the clear explaination

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

카테고리

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