How to store value generated from nested for loop in an array, in Matlab?

前端 未结 2 692
我寻月下人不归
我寻月下人不归 2021-01-27 13:38
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 ge

2条回答
  •  不思量自难忘°
    2021-01-27 14:35

    Try it like this:

    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
    

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

提交回复
热议问题