Info

This question is closed. Reopen it to edit or answer.

can you help me to correct this program i write it to remove the rows who The sum of its elements is zero

1 view (last 30 days)
for i=1:46
h=sum(ans(i,2:13))
i=i+1;
if h==0
ans(~any(ans,2),:)=[];
end
end

Answers (1)

Paolo
Paolo on 26 Jun 2018
For matrix a
a(~sum(a,2),:) = []
  6 Comments
Matt J
Matt J on 26 Jun 2018
For that matter, don't use i or j (the imaginary number) as a variable either. Use k, row, ii, index, or some other name instead.
Or, don't use i,j as the imaginary number. Use 1i or 1j instead.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!