writematrix with Range has problem.

조회 수: 15 (최근 30일)
Kyoungtak Kim
Kyoungtak Kim 2020년 3월 29일
편집: Kyoungtak Kim 2020년 3월 29일
Hello.
I am confusing while I am using 'writematrix'.
Here is the code have the problem.
for i=1:5
CellRange = ['A',num2str(i)];
writematrix(filename,'Sheet',1,'Range','CellRange')
end
I know the Range should be Character type.
for i=1:5
firstRow = i;
firstCol = 'C';
cellRange = [firstCol,num2str(firstRow)];
end
Result of cellRange is character type as I expected.
But when I applied this into upper code, it's error message said that 'The range must be a character vector of the form 'A1:B2' or 'A1''
Is there something adjust for this?
Thank you.
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 3월 29일
writematrix(filename,'Sheet',1,'Range',CellRange)
You are passing in literally the phrase CellRange as the range, instead of the content of it.
Kyoungtak Kim
Kyoungtak Kim 2020년 3월 29일
편집: Kyoungtak Kim 2020년 3월 29일
Thank you, Mr. Roberson
It was stupid mistake.
It works after I get rid of '".

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Code Generation, GPU, and Third-Party Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by