Some issues to take into consideration.
You appear to be trying to implement the nested function approach. I would suggest splitting your code into two main functions, one for each figure window. Another issue is that you are not capturing your component handles. You will need these to tell your callbacks which edit field to update, for example. Because the number of components will depend on the value the user enters, your handles will have to be captured in arrays.
While hObject will let you access the properties of the calling object, you will need a way to refer to other components on the same row. I suggest adding a Tag property that contains the value of your loop index, k. You can query the tag of the invoking component to let you know what handle in the array to reference.
I would not have your popup callback set the value of Ex and Ey. Instead, I would set these values as part of the Calculate callback. I would use your popup callback to clear the string value of the edit field as a flag that the result needs to be recalculated.
You can also use dot notation instead of get and set.
n = str2double(e.String);
Best Answer