How to insert a nested function by GUI in GUIDE?

I use GUIDE to write a GUI to solve three consecutive differential equations. In the run button, I need to call three additional equation functions, but the three equations cannot be used as m files alone (because the parameters between the three equations are related to each other). Need to be placed as a nested function at the bottom of the gui m file, but the GUI does not seem to recognize the parameters inside the nested function, and use ‘n=str2double(get(handles.edit4,'string'))' , The command found that the input parameters could not be read. What should I do with this situation? Thank you
For example, here is an equation function script for me. In this function, I need to call the result of the previous equation as a parameter and not as an external independent function. Therefore, I can only handle it as a nested function. ,so how can i do it ?
function du=Castor_Collision_2(t,u)
R=handles.R; %bold starting here
h=handles.h;
E2=handles.E2;
v2=handles.v2;
rho2=handles.rho2;
E=handles.E;
H1=handles.H1;
H2=handles.H2;
m=handles.m;
n=handles.n;
M=handles.M;
uy=handles.uy;
up=handles.up; %bold ending here
mu=(m-1)*(u(1)-uy)/(up-uy);
mp=(m-1)/(up-uy);
phi1=sech(mu);
phi2=1-phi1;
phi3=tanh(mu);
H=H1*H2/(2*(H1+H2)); % Kogut模型
alpha=(sqrt(3*(1-v2^2)./(rho2*E2)))./(4*h^2);
g=9.8;
p0=H*g;
a=sqrt(R.*u(1));
ap=(3*pi*p0*R)/(4*E);
K2=E*a;
Fmix=phi1*K2*u(1).^n+phi2*p0*pi*(a.^m./(ap^(m-2)));
du=[u(2);alpha*(phi1*phi3*mp*K2*u(1).^n - phi1*K2*n.*u(1).^(n-1) - ...
phi1*phi3*mp*p0*pi*a^m/ap^(m-2) - phi2*p0*pi*R*m*a^(m-1)/(2*a*ap^(m-2)))*u(2)-(Fmix/M)];
end

댓글 수: 2

Stephen23
Stephen23 2019년 1월 10일
편집: Stephen23 2019년 1월 10일
"What should I do with this situation?"
Avoid GUIDE. Write your own GUI, then you can use nested functions without any issues.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

태그

질문:

2019년 1월 10일

댓글:

2019년 1월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by