Info

此问题已关闭。 请重新打开它进行编辑或回答。

output results to different excel sheets

1 次查看(过去 30 天)
Linden
Linden 2013-8-15
关闭: MATLAB Answer Bot 2021-8-20
Hi I want to output my results to different excel sheets. All sheets share the same prefix plus a number to distingush them. For example,
for i = 1:5
X=y(:,i);
xlswrite('output',X,factor_i);
end
How can I make Matlab create sheets like factor_1, factor_2,...
Thanks.

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-15
编辑:Azzi Abdelmalek 2013-8-15
for i = 1:5
X=y(:,i);
xlswrite('output',X,sprintf('factor_%d',i);
end
%or you can use
strcat('factor_',num2str(i))
  2 个评论
Linden
Linden 2013-8-15
Thanks very much. I actually tried sprintf('factor_%s',i). Didn't work.
Azzi Abdelmalek
Azzi Abdelmalek 2013-8-15
编辑:Azzi Abdelmalek 2013-8-15
% sprintf('factor_%s',i) is for characters
e.g
i='r'
sprintf('factor_%s',i)
% for numbers use
i=3
sprintf('factor_%d',i)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by