Wrong vaules gotten for solving a differential equation after Matlab ODE45!

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];

 Accepted Answer

I need to calculte plot(T, dy), the plot (T,y) seems to be fine.
I need to calculate dy=dy/dT value.
thanks

More Answers (2)

You forgout about point here
123Capture.PNG

4 Comments

And also c*(1-y) part needs to be c.*(1-y)
thanks for your answers,
I add all points.
f=@(T,y) a.*exp(-b./T).*y.^c.*(1-y).^d;
it generated a 45x45 Matrix ?
Do you know what is wrong? thanks
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
the resulting of dy is a 45x45 matrix, it should be a 45x1 matrix
thanks

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 6 Feb 2020

Commented:

on 6 Feb 2020

Community Treasure Hunt

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

Start Hunting!