MATLAB: How to display result in Text Area in Matlab Appdesigner

app designer

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));

Best Answer

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;