Trying to code from polymath
Show older comments
Im supposed to turn this Polymath code into a Matlab code but Im not sure how. Please help. Its supposed show a graph like in the example.

1 Comment
Walter Roberson
on 29 May 2022
What happened when you followed my suggestion to set up the equations using the Symbolic Toolbox and then use the sequence shown in the odeFunction() documentation ?
Answers (1)
Walter Roberson
on 28 May 2022
0 votes
I suggest that you set up the equations using the Symbolic Toolbox, and that you then use the flow of control shown in the first example for odeFunction() to convert into something that you can use with ode45()
1 Comment
Walter Roberson
on 30 May 2022
Use syms to declare all of the non-constants. On the syms command line, declare each of the functions in function form, such as
syms X(V) T(V) Ta(V)
Now assign all of the constants and non-differential equations as variables, including for example
deltaH = 80770+delCp*(T-298)
Now define variables corresponding to all of the derivatives, such as
dX = diff(X, V)
For future reference: if you had second derivatives, you would take the derivative of the derivative, such as
d2X = diff(dX, V)
Now create equations such as
eqn1 = dX == -ra/Fao
You will have three equations.
Also define equations for the initial conditions, such as
IC1 = X(0) == -1
IC2 = dX(0) == 2
Create a vector of differential equations, and one of initial conditions
eqn = [eqn1; eqn2; eqn3]
ICs = [IC1; IC2; IC3]
Now follow the work flow shown in the documentation for odeFunction().
The diagram you posted does not appear to have initial conditions for the equations, and unfortunately without initial conditions you are not going to be able to re-create the plots.
Categories
Find more on Calculus 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!