How to display a calculation result into a Text Edit Field using App Designer

21 ビュー (過去 30 日間)
Malu
Malu 2020 年 8 月 5 日
コメント済み: Baejung Kim 2021 年 7 月 20 日
Hello,
As I am new to MATLAB and App Designer, I have the following problem :
I have a button with a callback function, where I am doing my calculations. In the end I have some results I would like to display in the TexEdit Field.
avgDiff = mean(diff(timestamp'));
fprintf('The average timestamp diff is %.3f\n', avgDiff)
Sync_rate = (nr.framescaptured/nr.frames logged) * 100 ;
fprintf('The synchronization rate is: %.2f\n', Sync_rate )
How can I write in the end of the function that it displays these values? I have added this in the end of my function and I would like to display the numerical values taken from the calculations.
Thank you in advance!

採用された回答

Monisha Nalluru
Monisha Nalluru 2020 年 8 月 10 日
From my understanding, you want to display the calculated values in the Edit Field.
For that you can create two Edit Field (Numeric) which has the component names as
  • Sync rate is
  • Avg timestamp diff is
In order to display the values in Edit field, add the following code in callback function of Push button
% after calculations
app.SyncrateisEditField.Value=Sync_rate;
app.AvgtimestampdiffEditField.Value=avgDiff
% you can also change name of Edit Diels in Component Browser
app.SyncrateisEditField.Background=[1 1 0] %add background colour to edit field
If you want to use only Edit Field (Text) convert the calculation into string using num2str() and display using above code
  2 件のコメント
Malu
Malu 2020 年 8 月 13 日
Thank you! It worked when I converted it to string .
Baejung Kim
Baejung Kim 2021 年 7 月 20 日
app.EditField.Value=Value
does not work for me, I mean the value does not appear in the text area.
Seems to me that something is wrong with my MATLAB...I don't know if it's the company's security is messing with something.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreate Custom UI Components についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by