Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
ziad abdul
ziad abdul 2018 年 6 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
for i=1:46
h=sum(ans(i,2:13))
i=i+1;
if h==0
ans(~any(ans,2),:)=[];
end
end

回答 (1 件)

Paolo
Paolo 2018 年 6 月 26 日
For matrix a
a(~sum(a,2),:) = []
  6 件のコメント
Image Analyst
Image Analyst 2018 年 6 月 26 日
Also DON'T use ans as a variable name. This is the default variable name but it's also a temporary, scratch variable that could be overwritten at any time unexpectedly so it's not something you should depend upon.
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.
Matt J
Matt J 2018 年 6 月 26 日
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!

Translated by