MatLabを使用してLotka-Volterra方程式を解くのを誰かが手伝ってくれるのではないかと思っていました。コードが機能していないようです。私は次のことをします:
ステップ1 -
次のコードを含むpred_prey_odes.mという名前のファイルを作成しました。
% the purpose of this program is to model a predator prey relationship
% I will be using the Lotka-Volterra equations
% Program consists of the following differential equations:
% dY1/dt = a * Y1 - c * Y1 * Y2
% dY2/dt = b * Y2 - d * Y1 * Y2
function dy = pred_prey_odes(t, y)
% function that is to be integrated
%select constants
a = 1;
b = 2;
c = 3;
d = 4;
%set up differential equations
dy = zeros(2,1);
dy(1) = a * y(1) - c * y(1) * y(2);
dy(2) = b * y(2) - d * y(1) * y(2);
コマンドウィンドウに次のコードを入力する前に、ファイルを保存して現在のディレクトリにあることを確認しました。
clc
tspan = [0, 20];
y0 = [10; 10];
ode = @(t, y) pred_prey_odes(t, y);
[t, y] = ode45(ode, tspan, y0);
plot (t,y)
ただし、プロットはポップアップしません。実際、matlabでは何も起こらず、コマンドウィンドウをクリアすることすらできません。clcと入力しても、何も起こりません...
どんな助けでもいただければ幸いです!
ありがとう!
-Sneha Inguva