MATLAB: Remove zeros from cell

removing zeros

Dear all, I have the following problem:
mydata{n}(m,l)
let say n=1:1:3; m=1:1:4 and l=1:1:100
I have many zeros in cell. How can I remove them:
the result for mydata{1}(:,:) looks like :
0.223811939491137 0.751267059305653 0.255095115459269 0.505957051665142
0.699076722656686 0.890903252535798 0.959291425205444 0.547215529963803
0.138624442828679 0.149294005559057 0.257508254123736 0.840717255983663
0.254282178971531 0.814284826068816 0.243524968724989 0.929263623187228
0.349983765984809 0.196595250431208 0.251083857976031 0.616044676146639
0.473288848902729 0.351659507062997 0.830828627896291 0
0.549723608291140 0.917193663829810 0.285839018820374 0
0.753729094278495 0.380445846975357 0 0
0.053950118666607 0 0 0
0.129906208473730 0 0 0
Thanks in Advance …

Best Answer

This replaces the zeros with empty square brackets:
mydata = { 0.223811939491137 0.751267059305653 0.255095115459269 0.505957051665142
0.699076722656686 0.890903252535798 0.959291425205444 0.547215529963803
0.138624442828679 0.149294005559057 0.257508254123736 0.840717255983663
0.254282178971531 0.814284826068816 0.243524968724989 0.929263623187228
0.349983765984809 0.196595250431208 0.251083857976031 0.616044676146639
0.473288848902729 0.351659507062997 0.830828627896291 0
0.549723608291140 0.917193663829810 0.285839018820374 0
0.753729094278495 0.380445846975357 0 0
0.053950118666607 0 0 0
0.129906208473730 0 0 0};
zero_idx = bsxfun(@eq, [mydata{:}], 0);
mydata(zero_idx) = {[]};