Need help to run this code
Afficher commentaires plus anciens
Hi Friends,
I need your help!!!
When I try to run this code, the following message appeared:
Undefined function 'FDE_PI1_Ex' for input arguments of type 'function_handle'.
Error in Example (line 15)
[t, y] = FDE_PI1_Ex(alpha,f_fun,t0,T,y0,h,param).
Can you please help me to run this?
alpha=[0.8];
w=1.2;N=10000;E1=1.2;E2=1.3;D=1.3;k1=2.1;k2=2.3;k3=1.5;k4=1.5;c=1.8;r1=1.3;r2=1.2;l=0.006170;
param=[w,N,E1,E2,D,k1,k2,k3,k4,c,r1,r2,l];
f_fun=@(t,y,par)[
w*N-(par(1)/N)*(E1*par(3)+E2*par(4))-w*par(1);
(par(1)/N)*(E1*par(3)+E2*par(4))-(D+k1)*par(2);
c*D*par(2)-(r1+k2)*par(3);
(1-c)*D*par(2)-(r2+k3)*par(4);
r1*par(3)+r2*par(4)-(l+k4)*par(5);
l*par(5)-w*par(6)];
t0=0;T=50;
y0=[1.2;2.8;1.2;2.8;1.2;2.8];
h=2^(-5);
%%%%%%%%%%%%%%%%%%%%%%%%%%
[t, y] = FDE_PI1_Ex(alpha,f_fun,t0,T,y0,h,param);
figure(1)
plot(t,y(1,:)) ;
xlabel('t') ; ylabel('S(t)') ;
%legend('x(t)') ;
%title('PI1');
Réponses (1)
Star Strider
le 27 Sep 2020
To use a function handle in a calculation, it is necessary to evaluate the function so it will be replaced by the numeric output of the function:
[t, y] = FDE_PI1_Ex(alpha,f_fun(t,y,par),t0,T,y0,h,param);
Of course, ‘t’, ‘y’,and ‘par’ (or whatever you intend to pass to ‘f_fun’) must already exist in your workspace.
2 commentaires
Star Strider
le 27 Sep 2020
You have to supply the correct variables to be passed to ‘f_fun’. I have no idea what they are, or what you are doing (or for that matter, what your code does). All I did was identify the problem and tell you how to correct it.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!