How to display result in Text Area in Matlab Appdesigner

435 ビュー (過去 30 日間)
Noor Zaim Syafiq Nor Azam
Noor Zaim Syafiq Nor Azam 2019 年 12 月 9 日
移動済み: Adam Danz 2022 年 11 月 23 日
Hi, I have a problem here where I could not display my result of the equation in the text area.
Below is the code.
The app.EIRP.Value is the text area.
pt = app.ouputpower.Value;
lbo = app.backoffloss.Value;
lbf = app.eartbranchingloss.Value;
at = app.antennagain.Value;
lu = app.uplinkloss.Value;
lp = app.pathloss.Value;
gte = app.gteratio.Value;
bfb = app.satbranchingloss.Value;
br = app.bitrate.Value;
app.EIRP2 = pt+at-lbo-lbf;
app.EIRP.Value = num2str(eval(app.EIRP2));
  1 件のコメント
Zain Ul Abidin
Zain Ul Abidin 2021 年 4 月 25 日
移動済み: Adam Danz 2022 年 11 月 23 日
How Can I add nultiple line in a single text area using differnt sprint commands

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

採用された回答

Adam Danz
Adam Danz 2019 年 12 月 9 日
編集済み: Adam Danz 2019 年 12 月 9 日
It's unclear whether you're working with numeric or text values. App designer has edit fields that return text and edit fields that return numeric values.
If you're working with text edit fields that contain numeric characters such as '42', you must convert them to numeric, do the math, then convert the result back to character (or string). Consider replacing the text edit fields with numeric edit fields
pt = str2double(app.ouputpower.Value); % converts from string/char to double
app.EIRP.Value = num2str(app.EIRP2); % converts from numeric to char
% -or -
app.EIRP.Value = sprintf('%.3f',app.EIRP2); % converts from numeric to char
% No need for eval (Ever)
If you're working with numeric edit fields there is no need to do any conversion.
pt = app.ouputpower.Value;
app.EIRP.Value = app.EIRP2;
  4 件のコメント
Malu
Malu 2020 年 8 月 5 日
編集済み: Adam Danz 2020 年 8 月 5 日
Hello,
as I am not much familiar with App Designer, I would ask for your help regarding a similar issue.
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')); %checking the acquisiton rate
fprintf('The average timestamp diff is %.3f\n', avgDiff)
Sync_rate = (S/5) * 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?
app.status(end+1,1) = {'Sync rate is... and then to display : "Avg timestamp diff is"'};
set(app.StatusWindowTextArea,'Value',app.status)
set(app.StatusColour,'Background',[0 1 0])
end
pause(1)
Thank you in advance!
Adam Danz
Adam Danz 2020 年 8 月 5 日
You can use sprintf to create a string that includes values from your variables. See examples in the link.
Then assign the string to the text box in the app using
app.TextBox.Value = ______

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

その他の回答 (2 件)

Bill Llach
Bill Llach 2022 年 4 月 16 日
編集済み: Bill Llach 2022 年 4 月 16 日
if you have a complex number vector just use:
evalc('anything')
Example:
someArray = [1 2 1 2];
theThingYouWantToShow = roots(someArray);
%theThingYouWantToShow is a vector with complex numbers (if you can show this, you can show anything :) (I guess) )
app.SomeTextArea.Value = evalc('theThingYouWantToShow');

Diego Roa
Diego Roa 2022 年 11 月 21 日
¿Como imprimir una función de transferencia en un texteditfield ?

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by