how to check if the row of the matrix equal zero or not

3 views (last 30 days)
Hi I would like to ask, how can I check each row of a matrix if it zero or not?? I wrote this program but it doesnot work. I need If the row equal zero do something else delete that row and do another thing.
m=[1 2; 2 3; 0 0 ; 9 9]
if m(:,2)==0 % check if one row is zero
m1=2+m % add 2 to that row
else
k=m(all(m==0,2),:)=[] % delete that row and create new vector (k)
end

Accepted Answer

Thorsten
Thorsten on 8 Aug 2016
k=m;
k(all(m==0,2),:)=[] % delete that row and create new vector (k)

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!