Check ode15s code to solve a double derivative DE

2 vues (au cours des 30 derniers jours)
James Ly
James Ly le 10 Août 2020
I'm pretty much a complete beginner and I've tried modifying an existing code to solve the Gilmore equation. I've attached the code in a txt file as well as a picture of the equations I'm trying to model.
Please let me know if I have to change anything.
  1 commentaire
Deepak Gupta
Deepak Gupta le 10 Août 2020
From line number 47:
H_0 = ; % Initial enthalpy
H_1 = ; % Final enthalpy (?)
These values are not defined. There is syntax error in line 103 also.
dydt = R*y(3)*(1/y(2)/c)+1.5*y(2)^2*(1-y(2)/(3*c)-H*z(2)*(1+y(2)/c) ;

Connectez-vous pour commenter.

Réponses (1)

Ayush Gupta
Ayush Gupta le 3 Sep 2020
There a couple of problems in the code, I would recommend breaking the function into two functions for ease of understanding. On line 47 there are no values initialized for H_0 and H_1. Also it gives a syntax error in
dydt = [y(3); R*y(3)*(1/y(2)/c)+1.5*y(2)^2*(1-y(2)/(3*c))-H*z(2)*(1+y(2)/c)];
The z variable which is used here is undefined or not initialized. To have a function call to get the equation inside the ode15s function check the documentation of ode15s and examples on how to use it here.

Community Treasure Hunt

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

Start Hunting!

Translated by