MATLAB: Trasform from a cell array into a matrix

cell arrayMATLAB

Hi! I want to represent the values in pairs (attached) in a matrix
A = [
21714 1067829 '';
21714 18417 '';
21714 9241 420315;
21714 420315 420315;
21714 211286 '']
can you help me?

Best Answer

This isn’t quite as efficient as I’d like it, but it works:
A={21714 1067829 ''; 21714 18417 ''; 21714 9241 420315; 21714 420315 420315; 21714 211286 ''};
LM = cellfun(@isempty, A, 'Uni',0);
LMN = find(cell2mat(LM));
A(LMN) = {NaN};
Result = cell2mat(A)
Result =
21714 1067829 NaN
21714 18417 NaN
21714 9241 420315
21714 420315 420315
21714 211286 NaN