- #1
mikeph
- 1,235
- 18
say,
how can I remove the rows of a that contain only zeros?
I found a link which works, but I don't know why:
http://www.mathworks.in/matlabcentral/newsreader/view_thread/281578
Suggesting:
1. what does the "=[]" syntax do
2. can this method be used to generate a second matrix b = a(without any zero rows)? I tried re-writing in this form and it doesn't work:
Clearly I'm missing something,
Thanks
Code:
a = [1,2,3; 0,0,0; 0,4,5];
how can I remove the rows of a that contain only zeros?
I found a link which works, but I don't know why:
http://www.mathworks.in/matlabcentral/newsreader/view_thread/281578
Suggesting:
Code:
a(all(a==0,2),:)=[]
1. what does the "=[]" syntax do
2. can this method be used to generate a second matrix b = a(without any zero rows)? I tried re-writing in this form and it doesn't work:
Code:
>> b = a(all(a==0,2),:)
b =
0 0 0
Clearly I'm missing something,
Thanks