phase portrait error when run

2 ビュー (過去 30 日間)
Latifah
Latifah 2023 年 2 月 6 日
回答済み: Sulaymon Eshkabilov 2023 年 2 月 6 日
i have an error when run this script, how to fix it ?
Output argument "lnear" (and maybe others) not assigned during call to "lnear".
Error in Untitled4>@(t,y)lnear(t,y) (line 11)
[t y] = ode45(@(t, y) lnear(t, y), tspan,iv);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Untitled4 (line 11)
[t y] = ode45(@(t, y) lnear(t, y), tspan,iv);
Function 'lnear' has already been declared within this scope.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 2 月 6 日
Here is the corrected code:
clc; clear
figure1=figure;
axes1=axes('Parent',figure1,'FontSize',13);
grid on;
box(axes1,'on');
hold(axes1,'all');
to = 0 ;
tf = 30;
tspan = to : 0.001 : tf ;
iv = [ 12.3 0.1 0 0.1 0.1 ] ;
iv2 = [ 12.3 0 0 0 0 ] ;
iv3 = [ 12.65 0 0 0.1 0.1 ] ;
iv4 = [ 12.65 0.1 0.1 0 0 ] ;
iv5 = [ 12.485594 0 0 0 0.12 ] ;
iv6 = [ 12.3 0.1 0 0.1 0 ] ;
iv7 = [ 12.4 0.05 0 0.05 0 ] ;
iv8 = [ 12.65 0.05 0 0.05 0.05 ] ;
iv9 = [ 12.6 0.05 0 0.05 0 ] ;
[t, y] = ode45(@lnear, tspan, iv.');
[t, x] = ode45(@(t, x) lnear(t, x), tspan, iv2.');
[t, z] = ode45(@(t, z) lnear(t, z), tspan, iv3.');
[t, n] = ode45(@(t, n) lnear(t, n), tspan, iv4.');
[t, w] = ode45(@(t, w) lnear(t, w), tspan, iv5.');
[t, v] = ode45(@(t, v) lnear(t, v), tspan, iv6.');
[t, s] = ode45(@(t, s) lnear(t, s), tspan, iv7.');
[t, p] = ode45(@(t, p) lnear(t, p), tspan, iv8.');
[t, c] = ode45(@(t, c) lnear(t, c), tspan, iv9.');
plot(y(:,1), y(:,5)), grid on
plot(x(:,1), x(:,5)), grid on
plot(z(:,1), z(:,5)), grid on
plot(n(:,1), n(:,5)), grid on
plot(w(:,1), w(:,5)), grid on
plot(v(:,1), v(:,5)), grid on
plot(s(:,1), s(:,5)), grid on
plot(p(:,1), p(:,5)), grid on
plot(c(:,1), c(:,5)), grid on
plot(12.485594+0*tspan,0+0*t,'k*','LineWidth',10)
xlabel('y_1'), ylabel('y_5')
function dydt = lnear(t,y)
e1 = 13;
g = 0.0125;
h = 0.284253;
f = 0.05 ;
q1 = 0;
k1 = 10;
d1 = 0.0412;
e2 = 0.0188;
j = 0.0082;
q2 = 0;
k2 = 10;
d2 = 0.0288;
b = 2;
d4 = 0.1152;
e3 = 0.166667;
a = 1.7 ;
q3 = 0;
k3 = 10;
d3 = 0.1152;
r = 0.5 ;
m= 1.02 ;
q4 = 0;
k4 = 10;
dydt = [e1 + (g*y(3)*y(1)/(h + y(3))) + (f*y(3)*y(1)) - (y(1)*(1 + ((q1/k1)*y(1)))) - (d1*y(1));
e2*y(2) + (f*y(1)*y(3)) - (j*y(2)) - (y(2)*(1 + ((q2/k2)*y(2)))) - (d2*y(2));
(b*e2*y(2)) - (d4*y(3));
e3*y(4) + (j*y(2)) - (a*y(4)) - (y(4)*(1 + ((q3/k3)*y(4)))) - (d3*y(4));
(r*y(5)*(1 - (m*y(5)))) + (a*y(4)) - y(5)*(1 + ((q4/k4)*y(5)));];
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by