Calculating limits, derivatives, and integrals in AppDesigner

조회 수: 7 (최근 30일)
BackBackDo
BackBackDo 2021년 1월 22일
댓글: rony guzman 2022년 9월 12일
Hello, I have a task to write a user interface for calculating limits, derivatives, and integrals.
In each function there is some problem because of which the GUI can not work completely on the user-defined data.
In the usual Matlab command line, everything works flawlessly, but in AppDesigner it does not work.
If someone knows how to do this, please explain.
For input data i'm use text fields.
Here's what I have:
Integrals:
function CalculateButtonPushed(app, event)
syms x
fun=app.integralEditField.Value;
xmin=app.downEditField.Value;
xmax=app.upEditField.Value;
f=int(fun,xmin,xmax);
app.ansIntegralEditField.Value=f;
end
Error: Undefined function 'int' for input arguments of type 'char'.
Limits:
function limcalcButtonPushed(app, event)
syms x
y=app.limitEditField.Value; %(x^3 + 5)/(x^4 + 7)
lim = limit(y);
app.limansEditField.Value=lim;
end
Error: Undefined function 'limit' for input arguments of type 'char'.
Derivative:
function divCalcButtonPushed(app, event)
syms x
f = 3*x^2 + 2*x^(-2);
f = diff(f);
app.divansEditField.Value=f;
end
Error:
Error using matlab.ui.control.EditField/set.Value (line 98)
'Value' must be a character vector or a string scalar.
Thank you.

답변 (1개)

Reshma Nerella
Reshma Nerella 2021년 1월 31일
Hi
There are two types of Edit Fields, one for Numeric values and the other one is for text.
If you try to store or retreive values from a from Edit Field(text), it will of type 'char'.
I think you are using Edit Feild(text) for downEditField, upEditField.
Convert the data type to the ones the functions(like int) support and then pass them as arguments
Since 'int' function doesn't take 'char' as input, it is showing you the error
Undefined function 'int' for input arguments of type 'char'.
For more information on Edit Field refer to the documentation page: uieditfield
Hope this helps!!

Community Treasure Hunt

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

Start Hunting!

Translated by