Ok, so semi-irrelevant information out of the way first - i'm writing a program that will give a basic model of the solar system - taking into account interactions from the planets on each other.(adsbygoogle = window.adsbygoogle || []).push({});

I can get my program running when containing the individual starting points of each of the planets in a massive row vector (say, X(1:12) but would rather (for simplicity, efficiency and making the next stage much easier..) have X(1,1:3) and X(2,1:3) so i can have a separate area for each planet.

Hopefully i won't have to provide much code - essentially when i transfer into arrays i'm getting the following problem when run:

"

??? Index exceeds matrix dimensions.

Error in ==> forcesar at 8

DX(1,1:6) = [X(1,4:6); -X(1,1:3)*GM(1)/norm(X(1,1:3))^3];

"

forcesar being a function that adjusts the data for other planetary effects - previous to the above line i've initialised DX as a zeroes(3,6) matrix so i don't see what the problem with filling it up is? (as far as i'm aware the error is essentially telling me i'm trying to put too many values into a smaller matrix) clearly i'm doing something wrong, either that or it's just not possible to do it this way.

as always, help much appreciated.

-fasterthanjoao

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab problem.

Loading...

Similar Threads for Matlab problem |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Does anyone had this plotting problem with MATLAB? |

**Physics Forums | Science Articles, Homework Help, Discussion**