MATLAB: How to declare all the rows and all column in matlab in a matrix or array?

neural network

suppose i need to remove all the zeros from a dataset and within a if else condition if the i no rows found zeros with all its column then the entire row will be deleted .. i need to know how to declare the entire row with column in matlab
is this the way to write c(:)=[]

Best Answer

"if [...] rows found zeros with all its column then the entire row will be deleted"
If the array is x, then
idx=~any(x,2); % logical vector T for rows all zero
x(idx,:)=[]; % remove those rows
NB: other scattered zeros will still be in the array and there's no way to remove them and keep a 2D array unless there's a fixed number in each row/column so the resulting length of each reduced row and column is a constant. This is an unlikely condition in general altho could be possible for specific cases.