MATLAB: Dynamic edit text box that displays only one number

dynamicedit textguiMATLAB

I have a GUI that I created out of GUIDE that has several edit text boxes that I want to display numbers with. The edit text box near/working with the slider works fine. However the other three text boxes (I am only using two so far for testing) keeps displaying multiple numbers instead of just replacing the old number with a new number. You can confirm this by extending the length of the edit text box and then run the program. How can I fix this?
For now just fixing the first edit text box is fine. The code of interest is line 257
set(handles.edit2,'string',num2str(P1_ydata));
This is the only code that I have that control the edit2 text box
I attached the code and its guide gui for convenience.
For anyone helping to test this, the program is simulating pressure change. So you will have to us the slider to control the input pressure, and bring the value near the pressure to pressure 1 to induce change, bring pressure 1 to pressure 2 to induce change, and so forth.

Best Answer

Gary - I suspect that the problem with the edit2 and edit3 text boxes is with the following two lines of code
set(handles.edit2,'string',num2str(P1_ydata));
set(handles.edit3,'string',num2str(P2_ydata));
Both P1_ydata and P2_ydata appear to be arrays given the previous lines of code as
P1_ydata = [get(handles.P1_signal, 'YData') P1];
P2_ydata = [get(handles.P2_signal, 'YData') P2];
If you are trying to show the most recent P1 and P2 data in these edit text boxes, then I would do
set(handles.edit2,'string',num2str(P1));
set(handles.edit3,'string',num2str(P2));
As an aside, do you mean for these to be edit text controls? Can the user edit these values? If not, then I would just switch these for the static text controls.
Related Question