MATLAB: Fill a matrix with same values

fillmatrix

Hi! I have a matrix like this:
[ 1 8 9 7 7 4]
[ 0 0 0 0 0 0]
[ 0 0 0 0 0 0]
[ 9 8 6 5 5 1]
[ 0 0 0 0 0 0]
And I want to fill it like this
[ 1 8 9 7 7 4]
[ 1 8 9 7 7 4]
[ 1 8 9 7 7 4]
[ 9 8 6 5 5 1]
[ 9 8 6 5 5 1]
It seems to be very easy, but I cannot realize how to do it. Thank you in advice!

Best Answer

Another way,
e=find(any(A,2));
[h,b]=histc(1:size(A,1),[e;inf]);
A=A(e(b),:);