Created
December 19, 2018 13:49
-
-
Save uliludmann/1abcd60c2669fc4bea67d3c510944f03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
% Finaler Ausgabevektor: | |
drdt = [v_in a_ges]'; %eigentlich geschwindigkeit und beschleunigung aber nach integration ortsvektor und geschwindigkeitsvektor | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment