如何存储生成的值从嵌套在阵列循环,在Matlab?

问题描述:

y = find(sA);
l = y + sA;

for i=1:10
  for j=1
      l = l + sA;
  end
  y = y + length(y);
end

我想知道如何存储为,每次迭代所产生的价值,在数组中。

I would like to know how to store the value that is generated for l, for each iteration, in an array.

当我尝试做类似L(L)= L + sA的;我获得'怪异'的结果。

When I try do something like l(l) = l + sA; I obtain 'weird' results.

请注意:请阅读我的评论贴在下面。谢谢!

NOTE: PLEASE READ MY COMMENTS POSTED BELOW. THANKS!

尝试这样的:

y = find(sA); %This is incredibly strange! What exactly are you trying to achieve with this line?
l = y + sA;

for i=1:10
  l = l + sA;
  StoredL(i, :) = l;
  y = y + length(y); %This line does nothing??? Why is it here?
end

我删除了你内心的循环,因为它是无所事事,对于j = 1将只运行一次有啥意义呢?

I removed your inner loop as it was doing nothing, for j = 1 will only ever run once so what's the point?