1

我有一些简单的东西,如下所示,我在其中调用脚本进行 5 次迭代。

for n=i:5
(call script)
end

如何将一个变量输出保存到 Excel。假设每次迭代的变量 A 都会发生变化:

A=5

A=2.7

A=6

. .

这可以在一列中保存到 Excel 中吗?

我应该使用: xlswrite('output.xlsx',A,..... 有一些范围吗?

4

1 回答 1

0

最好是做这样的事情:

for i=1:5
    % (call script)
    A(i) = i; % Or to the obtained value
end
xlswrite('my_xls.xls',A);

如果要保存更多值,则可以执行以下操作:

for i=1:5
    % (call script)
    A(i) = i; % Or to the obtained value
    B(i) = i; % Or to the obtained value
end
M = vertcat(A(:)',B(:)');
xlswrite('my_xls.xls',M);

xls 文件是在您的 Matlab 的当前目录中创建的。希望这可以帮助,

于 2012-10-15T23:51:16.200 回答