필터 지우기
필터 지우기

How do you do numerical integration of a function in App Designer?

조회 수: 6 (최근 30일)
Cayleigh Johnston
Cayleigh Johnston 2019년 8월 17일
답변: Jyotsna Talluri 2019년 8월 20일
Is it possible to use the 'integral' function as in Matlab. I am struggling to write a function in terms of variable, say f(x), and then do integration on that function in AppDesigner.
My function is similar to x*0.25*(x/0.2)^0.1*exp(-(x/0.2)^0.1), and would like to integrate between two bounds that are user inputs within App Designer.
  댓글 수: 1
Adam Danz
Adam Danz 2019년 8월 19일
Something in your app needs to trigger the function. It could be a button or a ValueChangedFcn. Once the function is invoked, from within the function you can extract all of the needed values from your GUI by using the app variable. You can write your function anywhere in your app and call it from the callback function.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jyotsna Talluri
Jyotsna Talluri 2019년 8월 20일
Use the numeric edit boxes to input the limits of integration and to display the result of integration.Function for integration can be written in your app and can be invoked by calling it in pushbutton callback. You can extract the values from editboxes in pushbutton callback .
methods (Access = private)
function results = func(app,n1,n2)
syms x;
f=@(x)x*0.25.*((x/0.2).^0.1).*exp(-(x/0.2).^0.1);
app.result.Value=integral(f,n1,n2);
end
end
% val1,val2,result are editboxes
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button (callback)
function ButtonPushed(app, event)
n1=app.val1.Value;
n2=app.val2.Value; % editbox values
func(app,n1,n2);
end
end

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by