I have a differential equation in which the equation contains a function. I don't know how to input and call the function to generate the graph I want. can you help me fix it
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Latifah Hanum
le 28 Juil 2022
Commenté : Latifah Hanum
le 28 Juil 2022
function fv=fgliom(T,y)
p1=0.0068;
p2=0.012;
p3=0.002;
i1=4.7*10^-8;
i2=4.7*10^-5;
i3=4.7*10^-8;
c1=510;
c2=510;
a1=510;
a2=510;
a3=510;
s1=1.8*10^-2;
s2=1.8*10^-3;
s3=1.8*10^-3;
v=2;
j=50;
b=0.2;
u=0;
fv=zeros(5,1);
fv(1)= p1*y(1)*(1-(y(1)/c1))-s1*y(1)*(y(2)+y(3))-(i1*y(1)*y(5))/a1+y(1);
fv(2)= p2*y(2)*(1-(y(2)+y(3))/c2)-s2*y(1)*y(2)-u*F[(y(5)]*y(1)-(i2*y(1)*y(5))/a2+y(2);
fv(3)= p3*y(3)*(1-(y(2)+y(3))/c2)-s3*y(1)*y(3)+u*F*(y(5))*y(1);
fv(4)= v*y(1)'*F*(-y(1)'/c1)*y(4)-(i3*y(4)*y(5))/a3+y(4);
fv(5)= j-b*y(5);
function fv=fnaik(T0,y0)
p1=0.0068;
p2=0.012;
p3=0.002;
i1=4.7*10^-8;
i2=4.7*10^-5;
i3=4.7*10^-8;
c1=510;
c2=510;
a1=510;
a2=510;
a3=510;
s1=1.8*10^-2;
s2=1.8*10^-3;
s3=1.8*10^-3;
v=2;
j=50;
b=0.2;
u=10^-3;
fv=zeros(5,1);
fv(1)= p1*y0(1)*(1-(y0(1)/c1))-s1*y0(1)*(y0(2)+y0(3))-(i1*y0(1)*y0(5))/a1+y0(1);
fv(2)= p2*y0(2)*(1-(y0(2)+y0(3))/c2)-s2*y0(1)*y0(2)-u*F*(y0(5))*y0(1)-(i2*y0(1)*y0(5))/a2+y0(2);
fv(3)= p3*y0(3)*(1-(y0(2)+y0(3))/c2)-s3*y0(1)*y0(3)+u*F*(y0(5))*y0(1);
fv(4)= v*y0(1)'*F*(-y0(1)'/c1)*y0(4)-(i3*y0(4)*y0(5))/a3+y0(4);
fv(5)= j-b*y0(5);
function fv=fturun(T1,y1)
p1=0.0068;
p2=0.012;
p3=0.002;
i1=4.7*10^-8;
i2=4.7*10^-5;
i3=4.7*10^-8;
c1=510;
c2=510;
a1=510;
a2=510;
a3=510;
s1=1.8*10^-2;
s2=1.8*10^-3;
s3=1.8*10^-3;
v=2;
j=50;
b=0.2;
u=10^-2;
fv=zeros(5,1);
fv(1)= p1*y1(1)*(1-(y1(1)/c1))-s1*y1(1)*(y1(2)+y1(3))-(i1*y1(1)*y1(5))/a1+y1(1);
fv(2)= p2*y1(2)*(1-(y1(2)+y1(3))/c2)-s2*y1(1)*y1(2)-u*F*(y1(5))*y1(1)-(i2*y1(1)*y1(5))/a2+y1(2);
fv(3)= p3*y1(3)*(1-(y1(2)+y1(3))/c2)-s3*y1(1)*y1(3)+u*F*(y1(5))*y1(1);
fv(4)= v*y1(1)'*F*(-y1(1)'/c1)*y1(4)-(i3*y1(4)*y1(5))/a3+y1(4);
fv(5)= j-b*y1(5);
clc;clear all;format long;
[T y]=ode45('ftuber',0 200,[10000 0 0 2000 0 500 140]',10^-7);
[T0 y0]=ode45('fnaik',0 200,[10000 0 0 2000 0 500 140]',10^-7);
[T1 y1]=ode45('fturun',0 200,[10000 0 0 2000 0 500 140]',10^-7);
figure (1);
plot(T,y(:,1),'.-',T0,y0(:,1),'.-',T1,y1(:,1),'.-');
title('Grafik A')
legend('u=50','u=30','u=25')
xlabel('waktu (hari)');
ylabel('MA(t) (sel)');
figure (2);
plot(T,y(:,1),'.-',T0,y0(:,1),'.-',T1,y1(:,1),'.-');
title('Grafik B')
legend('u=50','u=30','u=25')
xlabel('waktu (hari)');
ylabel('MA(t) (sel)');
figure (3);
plot(T,y(:,1),'.-',T0,y0(:,1),'.-',T1,y1(:,1),'.-');
title('Grafik C')
legend('u=50','u=30','u=25')
xlabel('waktu (hari)');
ylabel('MA(t) (sel)');
figure (4);
plot(T,y(:,1),'.-',T0,y0(:,1),'.-',T1,y1(:,1),'.-');
title('Grafik D')
legend('u=50','u=30','u=25')
xlabel('waktu (hari)');
ylabel('MA(t) (sel)');
figure (5);
plot(T,y(:,1),'.-',T0,y0(:,1),'.-',T1,y1(:,1),'.-');
title('Grafik E')
legend('u=50','u=30','u=25')
xlabel('waktu (hari)');
ylabel('MA(t) (sel)');
here i want


3 commentaires
Walter Roberson
le 28 Juil 2022
function [value,isterminal,direction] = eventfun(T1, y1)
value = [y1(5)>0, -y1(1)>0];
isterminal = [true, true];
direction = [0, 0]; %crossing both ways
end
Réponse acceptée
Sam Chak
le 28 Juil 2022
Equation 6 is a kind of ON/OFF switch that can be constructed using a scaled version of the signum function.
x = -1:0.001:1;
F = sign(x)/2 + 0.5;
plot(x, F, 'linewidth', 1.5)
ylim([-0.5 1.5]), grid on
If g = y(1), s = y(2), r = y(3), n = y(4), q = y(5), then for 
fq = sign(y(5))/2 + 0.5;
For
, you can probably create a dummy function for Eq. (7)
gdot = % type out Eq.(7) here
fgdot = sign(-gdot)/2 + 0.5;
8 commentaires
Sam Chak
le 28 Juil 2022

Would advise you to check ALL equations again, one by one, term by term:
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Model Building and Assessment dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
