Two-Body Problem By solving a system of differential equations, determine the orbit of two masses using Newton's law and the universal law of gravitation. Display an animation of the orbit. To obtain full credit, you will need to assign the position vectors of the two masses into the variables x1, y1 and x2, y2 over one full orbital period. The eccentricity of the orbit, masses, tspan times, and RelTol of the ode solver are pre-specified in the Learner's template. To view an animation of the orbit itself, you will need to uncomment the graphics code and run in MATLAB online or desktop. At this time, MATLAB Grader does not support animation. Script 1 e=0.7; m1=1; m2=4; 2 T=2*pi./(1-e). ^1.5; tspan=linspace(0, T, 1000); 3 options=odeset('RelTol',1.e-6); 4 %%%%% Solve differential equations for x and y using ode45 with arguments tspan and options. %%%%% Determine x1, y1 and x2, y2 6 % 7% 8 % 9 %%%%% graphics: UNCOMMENT TO RUN ON MATLAB ONLINE OR DESKTOP %%%%KKKKKKK 10 % k=0.1; 11 % R1-k* (m1)^(1/3); R2=k* (m2)^(1/3); %radius of masses 12% theta=linspace(0,2*pi); 13 % figure; axis equal; hold on; set (gcf, 'color', 'w'); 14 % axis off; 15 % xlim( [-2,5]); ylim([-2.5,2.5]); 16 % planet-fill (R1*cos (theta)+x1(1), R1*sin(theta)+y1(1), 'b'); 17 % sun-fill(R2* cos(theta) +x2(1), R2* sin(theta)+y2(1), 'r'); 18 % pause (1); 19 % nperiods=5; %number of periods to plot 20 % for j-1:nperiods My Solutions > Save C Reset MATLAB Documentation
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
please provide the code ASAP
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images