Getting error with the code in ode45 function

function dy = f(t,y)
y=[9,100];
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 = 0;
[t,y]=ode45(@f, t, inity);
plot(t,y)
end
This is code for Nernst-Planck equation and when i execute it with Matlab-2020RA version it is showing error as, Out of memory. The likely cause is an infinite recursion within the program.
Error in f (line 12)
[t,y]=ode45(@f, t, inity);
So help me to correct the code

 採用された回答

Stephan
Stephan 2021 年 5 月 14 日
編集済み: Stephan 2021 年 5 月 14 日

0 投票

t=[0 5];
inity = 1;
[t,y]=ode45(@f, t, inity);
plot(t,y)
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;
end

3 件のコメント

Mohith S
Mohith S 2021 年 5 月 14 日
Sir can you give me the full code correctly ,still im getting an error
Mohith S
Mohith S 2021 年 5 月 14 日
Now im getting this error if i use the above code u have given...
f(~, y)
f(~, y)
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Stephan
Stephan 2021 年 5 月 15 日
Please show the full code you use that gives error.

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

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2021 年 5 月 14 日

コメント済み:

2021 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by