The following is an equation in physics (Newton's Law of Gravitation), in which G is a constant equal to 6.673e-11, and m1, m2, and r are all vectors of size n by 1 .
How can this be calculated in matlab? and what is the array type of variable F ?
a.
F = G*m1.*m2./r^2;
F will be a scalar value.
b.
F = G*(m1.*m2)./r*r;
F will be a row array.
c.
F = G*m1.*m2./r.^2;
F will be a square matrix.
d.
F = G*m1.*m2./r.^2;
F will be a column vector.
e.
F = G*(m1.*m2) /r.*r;
F will be a scalar value.
Answer : Option(d) (F will be a column vector)
Explanation :
Given that m1,m2 and r are vectors of size n by 1 means
m1,m2,r are column vectors.And G is a constant.So this will be
calculated in matlab as follow.
G * m1 means multipling each element in m1 vector with G and there
is .* operator and ./ operator in between m1,m2 and m2,r which
means these operation are performed element by element.Example if
1,2,3 are elements in one vector and 4,5,6 are elements of another
matrix then .* will multiply element by element(1*4,2*5,3*6) which
results same vector size.So after performingn .* and ./ the result
is still column matrix.And r^2 is just like G*m1 ,powers each
elements by 2.So Finally the result F will be a column
matrix.
*********Comment me for any Queries and Rate me up************
Get Answers For Free
Most questions answered within 1 hours.