MATLAB Answers

xlswrite with formula in loop function

조회 수: 6(최근 30일)
JB
JB 19 Oct 2017
Commented: JB 19 Oct 2017
I have a large cell (2500,3) array which I want to export as a .xls file, but I want to include a formula ('=SUM(B1:C1)') which can be used in excel, The code below is working fine but I want the "B1" and "C1" to increase by 1 for each loop ('=SUM(B1:C1)', '=SUM(B2:C2)', '=SUM(B2:C2)' etc). How can I do this??? My present loop code is:
for II = 1:length(out)
out{II,4}='=SUM(B1:C1)';
end
xlswrite('Book1.xls',out)

  댓글 수: 0

로그인 to comment.

채택된 답변

Walter Roberson
Walter Roberson 19 Oct 2017
out{II,4} = sprintf('=SUM(B%d:C%d)', II, II);

  댓글 수: 1

JB
JB 19 Oct 2017
PERFECT, thanks Walter Roberson

로그인 to comment.

More Answers (1)

Fangjun Jiang
Fangjun Jiang 19 Oct 2017
num2str(II), e.g. num2str(3)

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그

제품


Translated by