Matlab:从多个运行脚本收集所有结果
我有一个脚本,可以生成一列36个值。 我会将这36个值保存在Excel中的行中 目前,我必须每次运行脚本,以便更改xlrange值,例如:A1到A1000 我尝试循环脚本,并尝试将值写入新变量的新列中,例如Matlab:从多个运行脚本收集所有结果,matlab,Matlab,我有一个脚本,可以生成一列36个值。 我会将这36个值保存在Excel中的行中 目前,我必须每次运行脚本,以便更改xlrange值,例如:A1到A1000 我尝试循环脚本,并尝试将值写入新变量的新列中,例如mm For i=1:1000 Scriptnamehere mm(i,:)=m or mm(:,i) Write in excel script here End 它无法识别mm的i。您必须预先分配矩阵mm: For i=1:1000 Scriptnamehere mm(i,:)=m o
mm
For i=1:1000
Scriptnamehere
mm(i,:)=m or mm(:,i)
Write in excel script here
End
它无法识别
mm
的i。您必须预先分配矩阵mm
:
For i=1:1000
Scriptnamehere
mm(i,:)=m or mm(:,i)
Write in excel script here
End
N = 1000; % number of iterations
num_rows = 36; % number of values in every iteration
mm = zeros(num_rows, N); % preallocation
for k = 1:N % don't use i as index variable
% call script with k, receive m
mm(:, k) = m;
end
可能使用simple assignemt mm=m(我假设m是您从脚本中获得的值),在您尝试为示例mm(1)分配36个值的情况下,这将不起作用。另一方面,我不建议使用
I
作为循环变量,因为它已经被Matlab预定义为虚数
For i=1:1000
Scriptnamehere
mm = m
Write in excel script here
End
现在使用
i
作为索引变量没有什么错。复数i的正确命名为1i
。关于这个问题应该有很多讨论。@patrik3+5*i
仍然是复数的有效表示法,因此可能会破坏代码。讨论时请注意,这是正确的,但最好始终使用1i
或1j
,而不要将i
或j
用作复数。也就是说,如果您总是使用1i
或1j
(matlab对此发出警告),应该不会有任何问题。