MATLAB: How to make the sum operation result from the value on a pop up menu

arrays popupmenu sum

I want to make the sum operation result from the value on a pop up menu. i just have 2 pop up menu , first pop up menu example (Jan Feb march) the value is (1 2 3), second (banana apple grape) the value is (2 3 4), if I choose Jan and banana (1 + 2 = 3) . and the result example I will display on static test.

Best Answer

If you want to add numeric values corresponding to which entry was chosen, then you should be using the Value property, not the string property.
lookup_table1 = [1 2 3];
lookup_table2 = [2 3 4];
v1 = get(handles.tag_daerah, 'Value');
v2 = get(handles.tag_PS, 'Value');
result = lookup_table1(v1) + lookup_table2(v2);
set(handles_hasil_js, 'string', result);