Dynamic edit text box that displays only one number

3 ビュー (過去 30 日間)
Gary Chen
Gary Chen 2016 年 7 月 13 日
編集済み: Gary Chen 2016 年 7 月 18 日
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.

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 7 月 18 日
編集済み: Geoff Hayes 2016 年 7 月 18 日
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.
  1 件のコメント
Gary Chen
Gary Chen 2016 年 7 月 18 日
編集済み: Gary Chen 2016 年 7 月 18 日
Hi Geoff. Thanks for the response. This changed worked exactly as I wanted. For the aside, I don't intend to have the text box to be edit controls. I will try out the static text as you mentioned

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by