xlswrite with formula in loop function

2 次查看(过去 30 天)
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)

采纳的回答

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

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by