MATLAB: Numeric values need to be equalize to symbolic values.

doublesymbolic

distances=[100 120;200 220]
points_id=[{'p1'} {'p2'};{'p3'} {'p4'}]
% I need to equalize each matrixes to each other.
%for example, 100='p1' , 120='p2' , 200='p3' , 220='p4'
%then, when I need to learn the numeric values symbol, for example, 220, I could be retrive 'p4' as a symbolic assigned value of 220.

Best Answer

Here are two functions, the first will find point_id given an element of the distances matrix:
pointfind = @(d) points_id(find(distances == d));
so
p = pointfind(220)
returns
p =
'p4'
and the second one will find the corresponding element in distances given an element in the point_id array:
distfind = @(p) distances(find(cellfun(@isempty, strfind(points_id, p)) == 0));
so
d = distfind('p4')
returns
d =
220