Trying to create a callback function on App Designer.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I can be considered as newbie for Matlab and am trying to create an application that calculates the nominal interest rate "i".
i = N*((T/P)^(1/(N*Y))) - N where
i = nominal interest rate
P = initial investment
T = future value
N = number of compounding periods per year
Y = number of years
The basic look of my application as following:

I want this application to execute the function that I gave above when you click the calculate button. In order to to that, I right click the calculate button and after that click callback then add the function up there. However, I do not know how to display it on the bottom field and I get an error when I click the calculate button as following, you can also see my callback function there: 

As a result, what is my mistake and what should I do to create this callback function properly and display its result on the "i" field?
Appreciated for your help.
0 Commenti
Risposte (1)
Harshavardhan
il 7 Feb 2025
Hi @Burak Akin
I understand that you are attempting to compute and display the value of the variable "i”. This calculation is based on inputs received from four "NumericEditField" components. When a button is clicked, a formula is applied to these inputs to determine the value of "i”.
The problem is that the variables “app.p_val”, “app.t_val”, etc., are objects rather than numeric variables. To get the numeric value of these fields you can use the property “Value”. For more information on “NumericEditField” you can type the following line in a MATLAB command window.
doc NumericEditField
Moreover, to see the value of the result, the “NumericEditField” “i” needs to be modified.
The code with the changes is given below:
function cal_butButtonPushed(app, event)
P = app.p_val.Value; % getting the Value of P
T = app.t_val.Value; % getting the Value of T
N = app.n_val.Value; % getting the Value of N
Y = app.y_val.Value; % getting the Value of Y
app.i_val.Value = N*((T/P)^(1/(N*Y))) - N; %calculating and setting the value of i
end
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!