I have the following arrays,
Names = [string('abc') string('def') string('ghi') string('jkl')]
SubName1 = [string('abc') string('jkl')]
SubValue1 = [-1 1]
SubName2 = [string('ghi') string('jkl')]
SubValue2 = [-2 1]
The array named SubValue1 contains the values that correspond to the keys(strings) in the array named SubName1.I want to compare SubName with Names and create a matrix that maps the key-value pair as follows
RowName SubName1 SubName2
abc -1 0
def 0 0
ghi 0 -2
jkl 1 1
To obtain the above matrix I'm trying the following,
Index1 = find(ismember(Names,SubName1))
Index2 = find(ismember(Names,SubName2))
>>Index1 = [1 4];
>>Index2 = [3 4];
I'm not sure how to proceed from here. Essentially, I am trying to fill the columns of the matrix with the values SubValue of the keysSubNames at the indices present in Index.
Any suggestions?