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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 6E
icon
Related questions
icon
Concept explainers
Question

please provide the code ASAP

for i=1:length(t)
21 %
22 %
23 %
24 %
25 %
26 % end
27 %%%%% Write local function for differential equations %%%%%%%%%
end
planet.XData=R1*cos(theta)
sun.XData=R2*cos(theta)+x2(i); sun.YData=R2*sin(theta)+y2(i);
+x1(i); planet. YData=R1*sin(theta)+y1 (i);
drawnow;
0/0/0/0/0/0/0/
10/0/0/0/0/0/0/0/0/0
Run Script
?
Transcribed Image Text:for i=1:length(t) 21 % 22 % 23 % 24 % 25 % 26 % end 27 %%%%% Write local function for differential equations %%%%%%%%% end planet.XData=R1*cos(theta) sun.XData=R2*cos(theta)+x2(i); sun.YData=R2*sin(theta)+y2(i); +x1(i); planet. YData=R1*sin(theta)+y1 (i); drawnow; 0/0/0/0/0/0/0/ 10/0/0/0/0/0/0/0/0/0 Run Script ?
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.
5
0/0/0/0/0/
%%%%% Determine x1, y1 and x2, y2
6 %
7 %
8 %
0/0/0/0/0/0/0/0/0/0/0/0
9 %%%%% graphics: UNCOMMENT TO RUN ON MATLAB ONLINE OR DESKTOP %%%%%%%%%%%%%%
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
Transcribed Image Text: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. 5 0/0/0/0/0/ %%%%% Determine x1, y1 and x2, y2 6 % 7 % 8 % 0/0/0/0/0/0/0/0/0/0/0/0 9 %%%%% graphics: UNCOMMENT TO RUN ON MATLAB ONLINE OR DESKTOP %%%%%%%%%%%%%% 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT