Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab:从多个运行脚本收集所有结果_Matlab - Fatal编程技术网

Matlab:从多个运行脚本收集所有结果

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

我有一个脚本,可以生成一列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 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
。关于这个问题应该有很多讨论。@patrik
3+5*i
仍然是复数的有效表示法,因此可能会破坏代码。讨论时请注意,这是正确的,但最好始终使用
1i
1j
,而不要将
i
j
用作复数。也就是说,如果您总是使用
1i
1j
(matlab对此发出警告),应该不会有任何问题。