Hi,
I made a bit of a time investment to get a system of equations into an ODE format in a seperate function file. These equations are dependent on time, but I wish to define a 1D geometry. say X=0:dx:10. I created the function file so that for every time point I solve all of my X's. In my X domain I give a step for a defined time perios over a defined distance and then leave it to work itself out. The problem I am running into now is that MatLab is wanting the output to be a column vector. Currently I have it set up such that I get a 2D matrix out. Each row is a differential equation and each column is a specific place in space. This is not an acceptable output for an ODE solver it seems.
I previously went around this problem before by setting up a Euler integration approach but I am running into the limits of MatLab memory constraints and need the variable step sizes that an ODE solver gives me. I have also looked into PDEPE and am not sure that this is the solution. I am still trying to see all of the option in the toolbox but I could use a helping hand.
Thanks,
Ryne

Respuestas (1)

Torsten
Torsten el 29 de En. de 2015

0 votos

Use reshape to transform your 2d-matrix to a column vector:
reshape(A,[neq*nx,1])
where neq is the number of differential equations and nx is the number of grid points in x direction.
Best wishes
Torsten.

3 comentarios

Michael Horn
Michael Horn el 29 de En. de 2015
That is a nice little trick! For completness, I had to create an initial conditions vector of length neq*nx by using either ones or zeros. Once the initial conditions were brought in I had to break them up into neq vectors of nx length. Then do the normal ODE thing and at the end I added the mentioned trick to place it into a single column of length neq*nx.
Still theory but I think it should work.
I'll come back!
Michael Horn
Michael Horn el 29 de En. de 2015
So this got my program to run through my ODE function file without anymore errors. The problem now is I am getting, what I believe, to be garbage on the other end. My question moves to what exactly the ODE solver does behind the scene from the end of my file (Output) back up to begining of my file (Input, initial conditions). I know there is some sort of error check, depending on the type of ODE being used, that alters the initial conditions. Does placing my 2D data into a 1D column effect this error checking? I believe that it would but I'm not entirely sure. Thoughts?
Torsten
Torsten el 30 de En. de 2015
Don't care about what the integrator does in the background.
You have to take care that you supply correct initial conditions and time derivatives for the variables.
The replacement of the 2D data to an 1D column has no effect on how the solver tackles your problem.
Best wishes
Torsten.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 28 de En. de 2015

Comentada:

el 30 de En. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by