Problem #3 for loop to sum the moments 1-D problem In statics, the sum of moment
ID: 2084614 • Letter: P
Question
Problem #3 for loop to sum the moments 1-D problem
In statics, the sum of moments applied on an object must be zero where the ith moment is defined as:
mi = Fidi
Where Fi is the ith force, di is the distance from the center of gravity and mi the ith moment caused by Fi. For the body to be stable:
F1d1 + F2d2 +...+FNdN =0
Write a program in MATLAB that will take the number of forces as input. Then it will go through a for loop for each force. In the for loop it will ask the value of the force , the distance from the center of gravity . Then it will iteratively calculate it corresponding moment and add it to the sum_moment. Once the for loop is exited, display the sum using disp command.
Submit the script as .m file
Explanation / Answer
While you writing a simple program in Matlab the best way to ensure that the value a user is inputting is a proper integer. or using such comparison and logical operation in the program Like....
when we want to repeat the same process so we using While and For loop.
The syntax by using the For loop.
mi = 0>=10
Fi= ~interger;
di=~interger;
i=[1.2.3.4.5.6.7.8.9.10];
sum=0;
for i=1:length(n)
(~m1)=(~F1*~d1)
end
for(~m2)=(~F2*~d2)
end;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.