MATLAB: Remove non-empty and zeroed cells from cell array.

cell arrays

hey
i have cell array like this:
myArray= {[],1,1,0.1,0.1;[],[],1,1,0.2;[],[],[],[],1;0.3,[],[],[],0.6;0.4,[],[],0.3 [];0.6,0.33,0.12,0.67,0.13;1,0.62,0.11,0.31,1;[],[],[],1,[]}
how to remove empty and zeroed cells from this array for each row. i have tried following which worked fine if i apply it on each row separately. but how to do it for whole array.
newArray=reshape(myArray(~cellfun(@isempty,myArray)),1,[]);
Thanks

Best Answer

A = myArray';
[~,ii] = find(~cellfun(@isempty,A));
out = accumarray(ii,[A{:}]',[],@(x){x'})