我想要知道我的这份代码(两个脚本)哪里需要修改,为什么会出现提示的错误,谢谢!
4 ビュー (過去 30 日間)
古いコメントを表示
脚本1
function dydt = jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr, Ir, Rq, Cq, U, P, Fc, L, beta)
dydt = zeros(3, 1);
dydt(1) = y(1)*(y(1) - 1)*(E*y(2) - K + K*y(2) + Rg*y(2) + Alpha*Cg + Alpha*K - Alpha*P - Alpha*T + A*Alpha*y(2) - Alpha*E*y(2) - Alpha*K*y(2) + Alpha*P*y(2) - Alpha*Rg*y(2));
dydt(2) = y(2)*(1 - y(2))*(Cr - Cq - Ir + Rq + A*y(1) + Fc*y(1) + U*y(3) + Alpha*P*y(1));
dydt(3) = y(3)*(1 - y(3))*(L*beta - E*y(2) + E*beta*y(2));
end
脚本2
figure(1);
Rg = 70; E = 100; T = 5; Cg = 20; A = 20; Alpha = 0.3; Cr = 80; Ir = 30; Rq = 50; Cq = 0; L = 100;
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr, Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
plot3(y(:,1), y(:,2), y(:,3), 'rh-', 'linewidth', 1);
hold on;
Rg = 70; E = 100; T = 5; Cg = 20; A = 20; Alpha = 0.6; Cr = 80; Ir = 30; Rq = 50; Cq = 0; L = 100;
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr, Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
plot3(y(:,1), y(:,2), y(:,3), 'g--', 'linewidth', 1);
hold on;
Rg = 70; E = 100; T = 5; Cg = 20; A = 20; Alpha = 0.9; Cr = 80; Ir = 30; Rq = 50; Cq = 0; L = 100;
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr, Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
plot3(t,y(:,1), y(:,2), y(:,3), 'b:', 'linewidth', 1);
hold on;
提示错误:
出错 jiaoyijizhi1>@(t,y)jiaoyijizhi(t,y,Rg,E,T,Cg,A,Alpha,K,Cr,Ir,Rq,Cq,U,P,Fc,L,beta) (第 4 行)
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr, Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
出错 odearguments (第 92 行)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
出错 ode45 (第 104 行)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
出错 jiaoyijizhi1 (第 4 行)
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr, Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
1 件のコメント
回答 (1 件)
cdarling
2024 年 7 月 17 日
报错信息如下,第一行即说明了问题,在你的程序中,没有定义K是什么
因此在脚本2中第三行,程序不知道要给jiaoyijizhi传入什么K值
应该像第二行中定义其他值一样,定义K的值
函数或变量 'K' 无法识别。
出错
jiaoyijizhi>@(t,y)jiaoyijizhi(t,y,Rg,E,T,Cg,A,Alpha,K,Cr,Ir,Rq,Cq,U,P,Fc,L,beta)
(第 4 行)
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr,
Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
出错 odearguments (第 92 行)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
出错 ode45 (第 104 行)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode,
tspan, y0, options, varargin);
出错 jiaoyijizhi (第 4 行)
[t, y] = ode45(@(t, y) jiaoyijizhi(t, y, Rg, E, T, Cg, A, Alpha, K, Cr,
Ir, Rq, Cq, U, P, Fc, L, beta), [0 50], [0.1 0.1 0.1]);
另外,看你的报错信息,你可能把“脚本1”的文件名写成“jiaoyijizhi1”了,但它的函数名是“jiaoyijizhi”,差一个1,这里可能也有点小问题
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Big Data Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!