How to append array:mass=2e30*N.ones((100,1)) to have 3 more bodies with mass 2e32?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charl vallily
    New Member
    • Jan 2011
    • 1

    How to append array:mass=2e30*N.ones((100,1)) to have 3 more bodies with mass 2e32?

    I'm pretty new to this but i am making a program to simulate gravitationally interacting bodies. So i have 100 bodies all the same mass and i want to append it so that i have 100 bodies all the same mass and 3 bodies with 100xthe original mass i f you catch my drift? (they are to simulate dense regions such as black holes). my original code looks like this:

    mass=2e30*N.one s((100,1))

    and i want the new array to be 103 masses with 3 of them with mass 2e32! how do id this?

    thanks!
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    You do not assign the same values to 100 different variables. You use the same variable 100 times, usually in a loop. And the same for the larger mass. Assign the larger mass to one variable and use it however many times you wish. Without any code posted there is no way to tell what you are trying to do, so no more can be said.

    Comment

    Working...