フィルターのクリア

using ode15s to solve differential equations

2 ビュー (過去 30 日間)
KayLynn
KayLynn 2014 年 2 月 11 日
コメント済み: KayLynn 2014 年 2 月 11 日
I am trying to solve differentials equations using ode15s. Have the following code:
function ode15s =(t,y);
%Define initial values of k1, k2,k3,S,P,E and C
k1=.005;
k2=.005;
k3=0.1;
S=100;
P=0;
E=10;
C=0;
y(1)=E;
y(2)=S;
y(3)=C;
y(4)=P;
y1=k2*y(3)+k3*y(3)-k1*y(1)*y(2);
y2=k2*y(3)+k1*y(1)*y(2);
y3=k1*y(1)*y(2)-(k2+k3)*y(3);
y4=k3*y(3);
y0=[0,0];
[t,y,k]=ode15(t,y);
I am getting the following errors: ode15s Error: File: ode15s.m Line: 1 Column: 12 Unexpected MATLAB operator.
>> ode15s Error: File: ode15s.m Line: 1 Column: 18 Unbalanced or unexpected parenthesis or bracket
I tried to rename the function (change it from ode15s and i get an error that says whatever i change it too it says that that name is recgoznied by matlab as ode15). I do not know how to fix this and/or what i may be missing in this code

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 11 日
編集済み: Azzi Abdelmalek 2014 年 2 月 11 日
You have a problem in the first line
function ode15s =(t,y)
Read the documentation about ode15s
doc ode15s
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 11 日
I don't think you read the documentation.
KayLynn
KayLynn 2014 年 2 月 11 日
function X = question3(t,y)
y=[10 100 0 0]; %Define initial values of k1, k2,k3,S,P,E and C k1=.005; k2=.005; k3=0.1;
%y(1)=E;
%y(2)=S;
%y(3)=C;
%y(4)=P;
x(1)=k2*y(3)+k3*y(3)-k1*y(1)*y(2);
x(2)=k2*y(3)+k1*y(1)*y(2);
x(3)=k1*y(1)*y(2)-(k2+k3)*y(3);
x(4)=k3*y(3);
[t,y,k]=ode15(t,y);
Attempted to change code accordingly and still running into problems. Not sure what I am missing

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by