1

Suppose I have a matrix called A:

3 0 3 3
0 0 4 0

And I have this function:

while(1)
  if all(A(:,i) == 0)
    i = i + 1;
  else
    i = i + 1
    break;
  end
end

How can I improve the performance of this code?

4

1 回答 1

3

非常简单地:

i = sum(all(A==0,1),2)
于 2012-11-10T14:01:44.153 回答