How to call a private function in a static function in App Designer?
Show older comments
Hello,
I want to make an app in Matlab App Designer to take some values and show some plots acordingly.
I made a simple interface with some plots, some edit fields and a plot button.
I want to take value from edit fields ( values that are typed manually by the user ) and after to plot. After I modify the values in edit fields and press plot button again, I want to see the changes that occur when I changed the variables, no matter how many times I edit values in edit fields and press the button.
The problem is that I can't have it to get working.
I created a function called func2(app) and I want to call it in my static function called anaerob(~,x).
In func2 I have this:
methods (Access = private)
function k1 = func2(app)
k1 = app.k1EditField.Value;
end
end
In this one I want to have the values that will be put later in edit fields.
And I want to declare it in my anaerob function:
methods ( Static )
function xd = anaerob(~,x)
xd=zeros(6,1);
func2(app)
k1=3.2;
k2=16.7; k3=1.035; k4=1.194; k5=1.5;
k6=3; k7=0.113; u10=0.2; u20=0.5; KM1=0.75; KM2=4; KI2=21;
c1=1; c2=1; Dd=0.05; S1in=10;
u1_S1=u10*(x(2)/(KM1+x(2)));
u2_S2=u20*(x(4)/(KM2+x(4)+x(4)^2/KI2));
fi1=u1_S1*x(1);
fi2=u2_S2*x(3);
cp=0.32;Qp=cp*x(6);
QCO2=1;
xd(1)=fi1-Dd*x(1); %X1
xd(2)=-k1*fi2-Dd*x(2)+ Dd*S1in; %S1
xd(3)=fi2-Dd*x(3); %X2
xd(4)=k3*fi1-k2*fi2-Dd*x(4); %S2
xd(5)=k4*fi1+k5*fi2-Dd*x(5)-QCO2; %S3
xd(6)=k7*fi1+k6*fi2-Dd*x(6)-cp*x(6); %P
end
end
This is the plot button callback:
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: PLOTButton
function PLOTButtonPushed(app, event)
t0=0;tf=30;x0=[20 9 5 32 10 10];
[~,x]=ode45(@app.anaerob,[t0 tf],x0);
plot(app.UIAxes,x(:,1))
plot(app.UIAxes_2,x(:,2))
plot(app.UIAxes_3,x(:,3))
plot(app.UIAxes_4,x(:,4))
plot(app.UIAxes_5,x(:,5))
plot(app.UIAxes_6,x(:,6))
clear; close all;
end
end
Thank you in advance for help!
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!