Question

In: Computer Science

(MATLAB) im trying to solve an equation for gravitational force for 41 radius values in between...

(MATLAB) im trying to solve an equation for gravitational force for 41 radius values in between 3.8e8 to 4e8, heres a snippet of the code... how would a create this equation to solve for all 43 values (3.8e8 - additional 41 values in between- 4e8) the values are evenly spaced. (MATLAB)

r=(3.8e8:(2e7/42):4e8);
Mass_earth=5.97e24;
Mass_moon=7.34e22;
Force=((G*Mass_earth*Mass_moon)/(r^2));
fprintf(''),disp(Force(1))

Solutions

Expert Solution

The code to solve for all 43 values of 'r'

clc;clear;
r = (3.8e8:(2e7/42):4e8);
Mass_earth=5.97e24;
Mass_moon=7.34e22;
G = 9.8;
Force=((G*Mass_earth*Mass_moon)./(r.^2)); % added vector operators ./ and .^
fprintf(''),disp(Force)

Sample output of the code

Remarks

The variable 'r' is basically an array of 43x1 element. So to perform operations element wise operations of ^, *, /,.. we have to use the operators .^ ./ and .* in Matlab. Otherwise we have to use the loop. if loop is used then the last two lines of code can be rewritten as

for i = 1:43
Force=((G*Mass_earth*Mass_moon)/(r(i)^2)); % used / and ^ operators
fprintf(''),disp(Force);
end


Related Solutions

Im trying to solve a babking problem for an inline course, it says to prepare someones...
Im trying to solve a babking problem for an inline course, it says to prepare someones bank reconciliation, what should my final answer look like?
What is the magnitude of the average gravitational force between the Sun and Mercury? What is...
What is the magnitude of the average gravitational force between the Sun and Mercury? What is the magnitude of the average gravitational force between the Sun and Mercury if the orbital radius of Mercury was doubled? (you will have to look up Newton's Universal Law of Gravitation and some values of mass and distance) and please list them with the solution. Please answer in scientific notation and round to three significant figures.
This is a Matlab Question Create MATLAB PROGRAM that can solve First Order Linear Differential Equation...
This is a Matlab Question Create MATLAB PROGRAM that can solve First Order Linear Differential Equation ( 1 example contains condition and the other does not have condition). 1. ty′ + 2y = t^2 − t + 1, y(1)=12 The correct answer is y(t) = 1/4 t^2 − 1/3 t + 1/2 + 1/12t^2 2. (x-1) dy/dx + 2y = (x+1)^2 The correct answer is y = (x(x+1) / x-1 ) + C(x+1) / x-1 The correct answer is
Calculate both the repulsive and gravitational force between a He atom and a B atom that...
Calculate both the repulsive and gravitational force between a He atom and a B atom that are 7x10^-15m apart from one another?
Hello! Im trying to solve a problem that involves calculating the Fiscal policy multiplier (non-exogenous, that...
Hello! Im trying to solve a problem that involves calculating the Fiscal policy multiplier (non-exogenous, that is, depending on the Interest rate): Task 1: Fiscal policy in the IS - LM model The following represent demand functions for consumption, investment and money: C = 80 + 0.8(Y - T) (1) I = 150 - 1000i (2) M/P = 0.2Y - 1000i (3) The price level is constant, the real money supply is 50 units and taxes are independent of income....
1) Use MATLAB to solve this differential equation. ??/?? = .25? (1 − ?/4 ) -...
1) Use MATLAB to solve this differential equation. ??/?? = .25? (1 − ?/4 ) - a 2) Use MATLAB to graph solution curves to this system with several different initial values. Be sure to show at least one solution curve for each of the scenarios found in ??/?? = .25? (1 − ?/4 ) - a ( let a = 0.16)
The gravitational attractive force between two bodies with masses m1 and m2 separated by a distance...
The gravitational attractive force between two bodies with masses m1 and m2 separated by a distance d is given by: F = Gm1m2 d 2 where G is the universal gravitational constant: G = 6.673 × 10−8 cm3 g × sec2 Write a function definition that takes arguments for the masses of two bod- ies and the distance between them and that returns the gravitational force. Since you will use the preceding formula, the gravitational force will be in dynes....
Determine the equation of the relationship between the force and the extension. Hooke's Equation: Fs =...
Determine the equation of the relationship between the force and the extension. Hooke's Equation: Fs = -k(delta)x
Write a function to solve the two-dimensional in Matlab, unsteady heat conduction equation with no internal...
Write a function to solve the two-dimensional in Matlab, unsteady heat conduction equation with no internal heat generation on a square domain. The length of each side of the square is 1 m. The function will have the following 4 inputs: npts                     number of grid points in each coordinate direction nt                         number of time steps to take dt                         size of time step (s) alpha                   thermal diffusivity (m2/s) Use the following initial and boundary conditions: Initialize the body to T =...
Solve this differential equation using Matlab yy' + xy2 =x , with y(0)=5 for x=0 to...
Solve this differential equation using Matlab yy' + xy2 =x , with y(0)=5 for x=0 to 2.5 with a step size 0.25 (a) Analytical (b) Euler (c) Heun d) 4th order R-K method Display all results on the same graph
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT