MATLAB: Change non-numerics into NaN & split cell array by delimiter

cell arraysplit cell

I have a 3000×1 cell array of depth in centimeters with both letters and numbers
EX:
A = {organic layer, 5~10, 15~20, 30~50, not specified}
I want to change all of the non-numeric bins into NaN and then split this array into both the lower and upper bound of depth so that
Lower Bound = {NaN, 5, 15, 30, NaN}; Upper Bound = {NaN, 10, 20, 50, NaN};
I tried to use numind = cellfun(@isnumeric, A) to find the numeric indices and then from that find all of the indices that ARENT numeric, to replace with NaN, but it simply says that all of the bins are not numeric because of the '~' between the integers.
Is there any way that I could accomplish this?
Thanks, Melissa

Best Answer

Once you've fixed the numeric values in you cell array, with for example:
Depthcm(cellfun(@(x) isnumeric(x), Depthcm)) = {''};
You can get your arrays with:
splitdepth = regexp(Depthcm, '~', 'split');
splitdepth(cellfun(@(c) numel(c) == 1, splitdepth)) = {{'Nan' 'NaN'}};
bounds = str2double(vertcat(splitdepth{:}));