Error with ode45

1 回表示 (過去 30 日間)
Mohith S
Mohith S 2021 年 5 月 14 日
回答済み: Star Strider 2021 年 5 月 14 日
function dy = f(~,y)
% y=[9,100]; dont overwrite y
D=0.00000001;
F=96485;
Z=0.000000016;
R=0.08206*298;
C=0.05;
J=-((D*Z*F*C)/R);
dy = J.*y;
t=[0 5];
inity = 1;
[t,y]=ode45(@f, t, inity);
plot(t,y)
end
For this code im getting error like this,f(~, y)
f(~, y)
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Please help me to correct the code...

採用された回答

Star Strider
Star Strider 2021 年 5 月 14 日
Supply the ‘t’ argument even if the code does not use it.
Try this —
t=[0 5];
inity = 1;
[t,y]=ode45(@f, t, inity);
plot(t,y)
function dy = f(t,y)
% y=[9,100]; dont overwrite y
D=0.00000001;
F=96485;
Z=0.000000016;
R=0.08206*298;
C=0.05;
J=-((D*Z*F*C)/R);
dy = J.*y;
end
.

その他の回答 (0 件)

カテゴリ

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