Skip to content

Instantly share code, notes, and snippets.

View uliludmann's full-sized avatar

Ulrich Ludmann uliludmann

View GitHub Profile

Keybase proof

I hereby claim:

  • I am uliludmann on github.
  • I am uludmann (https://keybase.io/uludmann) on keybase.
  • I have a public key ASBG81-zOO9PnFXYYymR8tV2quYExp2rrhE0ZYTfsPMQ9Qo

To claim this, I am signing this object:

function [drdt] = f_PlanSim_Multibody(t, r, G, m)
%% Init der Variablen:
r_in = r(1:length(r)/2); %Transpose vector input
v_in = r(length(r)/2 + 1:end); %velocity vector input
distances = squareform(pdist(r_in)); %euclidean distances of the n bodies as square matrix.
a = G * ( m / distances^2 ); %% matrix form of gravitational
a = a(a~=0 & isfinite(a)); %% remove infinity values
a_ges = sum(a, 2);