Question

The center of mass is the point where the mass of all particles in a system is considered to be concentrated. In one dimens

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

% prompting user for vector of mass
masses = input("Enter mass vector using [] brackets, e.g [1 2 3 5 9] : ");
% prompting user for vector of positions
positions = input("Enter position vector using [] brackets, e.g [1 2 3 5 9] : ");

sum_of_mass = 0; % to store m1 + m2 + m3 .....
product_of_mass_pos = 0; % to store m1*x1 + m2*x2 + ....

for i = 1:size(masses, 2)
sum_of_mass = sum_of_mass + masses(i);
product_of_mass_pos = product_of_mass_pos + masses(i)*positions(i);
end

% centre of mass
cm = product_of_mass_pos/sum_of_mass;
% printing the result
fprintf("The centre of mass is: %.2f\n", cm);

centreOfMass. mx 1 % prompting user for vector of mass masses = input(Enter mass vector using [] brackets, e.g [1 2 3 5 9] :

OUTPUT:

>> centreOfMass Enter mass vector using [] brackets, e.g (1 2 3 5 9] : [0.1 0 0.20 0.80 0.10] Enter position vector using []

Add a comment
Know the answer?
Add Answer to:
The center of mass is the point where the mass of all particles in a system...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT