idx = a == 0 ; % find indices of zeroes in a
b(idx) = [] ; % remove the respective values from b
If a is floating point numbers (which are mostly), you should prefer using this:
tol = 10^-5 ;
idx = abs(a)<=tol ; % find indices of zeroes in a
b(idx) = [] ; % remove the respective values from b