How to call sigmoid function inside runge kutte orde 4? Is it possibel?

조회 수: 1 (최근 30일)
I have sigmoid function and I want to call that function with runge kutte, how to call function inside function?

채택된 답변

Image Analyst
Image Analyst 2023년 6월 3일
편집: Image Analyst 2023년 6월 3일
To call a function from within another function, just call the function by name and pass it the arguments it wants. For example, to have it call a function called "function2" inside another function called "function1", do this:
function function1()
output = function2(input1, input2, input3);
end
Make sure you give the "inside" function whatever arguments it needs.
To learn other fundamental concepts, invest 2 hours of your time here:
  댓글 수: 2
cindyawati cindyawati
cindyawati cindyawati 2023년 6월 3일
Thanks for your response @Image Analyst. But, I already try with another code. I get error like this. What does the error mean?
function S = sigmoid (M1)
M1(j+1)= M1(j)+1./(1+exp(-T(j)));
function M1 =fRK4M1(K1,K2,M1,M2,M3,O,P,S)
M1=10;
M2=0;
M3=0;
O=0;
P=0;
Ko=0.1;
n=3;
Oa=10;
Pa=100;
mu_1=10^-3;
mu_2=10^-3;
mu_3=10^-3;
mu_o=10^-4;
mu_p= 10^-5;
K2=5*10^-4;
K3=10^-3;
gamma=75;
delta= 50;
M1 = (delta*M1*(1-(M1/gamma))-2*K1*M1*M1-M1*(K2.*M2)-((Oa-n)*K3*M1*M3)-((Pa-Oa)*Ko*M1*O)-(mu_1*M1));
end
end
Image Analyst
Image Analyst 2023년 6월 3일
Why did you not assign values for, and pass the variables in for, K1,K2,M1,M2,M3,O,P,S? Why did you call fRK4M1 with not enough (any actually) input arguments? Did you think MATLAB would just somehow automatically invent values for those variables? It won't. You have to assign them.
What is the name of your m-file? It appears to be fRK4M1.m, which is the name of a nested function. It should be sigmoid.m, which is the outermost function. And you need to assign and pass in M1 when you call sigmoid().

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by