Wrong vaules gotten for solving a differential equation after Matlab ODE45!
Show older comments
I run the following code to calculate dy/dT values, however, I found it gave wrong values (~6.3907232e+08) compared to use excel computed values (less than 0.03)
In excel, I simply input y and T values into equation and calculate all dy/dT values. Can you tell me what is wrong in my code? How to get the correct values for differential equation.
equation: dy/dT= a*exp(-b/T)*y.^c*(1-y).^d
clear
tspan=[360,456];
y0=0.000002;
a=30000000;b=8000;c=0.6;d=1.35;
f=@(T,y)(a*exp(-b/T)*y.^c*(1-y).^d);
[T,y]=ode45(f,tspan,y0);
data=[T,y];
dy=f(T,y);
data=[T,y,dy];
1 Comment
darova
on 6 Feb 2020
I used your code

Accepted Answer
More Answers (2)
Jingbo Wu
on 6 Feb 2020
0 votes
darova
on 6 Feb 2020
0 votes
You forgout about point here

4 Comments
James Tursa
on 6 Feb 2020
And also c*(1-y) part needs to be c.*(1-y)
Jingbo Wu
on 6 Feb 2020
James Tursa
on 6 Feb 2020
Edited: James Tursa
on 6 Feb 2020
What generated a 45x45 matrix?
Typically, this can result from using a row and a column vector in an operation. The fix is to make them all row vectors or all column vectors. E.g.,
>> row = 1:5;
>> col = row';
>> row.*col
ans =
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
>> row.*row
ans =
1 4 9 16 25
>> col.*col
ans =
1
4
9
16
25
Jingbo Wu
on 6 Feb 2020
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!