can someone help with this?

1 view (last 30 days)
michail popovits
michail popovits on 13 Oct 2021
Commented: Image Analyst on 14 Oct 2021
The script needs to
  • accepts any number (determined by the program user at run-time) of user-input 2-D force vectors (in component form, with x-, y- magnitudes AND force application point);
  • You might ask the user how many vectors will be input (which is easier to code), or
  • You can use a signaling mechanism - for example, ask the user whether there are more vectors to input, and continue if there is an affirmative response (which is more interesting and/or user-friendly).
  • accepts the x, y coordinates of a reference point within the defined square space;
  • calculates the equivalent force/couple system at the reference point, due to the applied forces at the true application points
test case:
Force one: (25, 25) pounds at location (10, 5)
Force two: (-40, 5) pounds at location (4, 7)
Force three: (20, -10) pounds at location (3, 2)
Reference point: (5, 5)
The script will be graded for
  1. Adherence to directions;
  2. User-friendliness of input and output;
  3. Use of Matlab output functions “disp” and “fprintf” to make the output well-understandable by the script user, and
  4. Clear, correct and understandable input statement prompts, and
  5. Suppression of all unnecessary output values and
  6. Adequate responses so that the user understands what user actions have been incorrectly done
  7. Correctness of the result when I run it for my own separate test case;
  8. Good programming practice, including proper documentation of the completed m-file
  9. Good practice includes use of whitespace to make the code readable, and
  10. Documentation includes sufficient comment statements to
  11. allow a human reader to understand well the intent and method of the script and
  12. allow me to know who wrote it and when, and what the variable names represent
the script is:
ThemeCopy
n_vectors = input("How many vectors would you like to input? "); %Initial inputs
referencex = input("What is the x-value of the reference point? ");
referencey = input("What is the y-value of the reference point? ");
sum_Fx = 0; %Defining variables that will be used later
sum_Fy = 0;
moment = 0;
for total = 1:n_vectors %For loop makes the program ask for the desired number of vectors
xi = input("What is the horizontal component of the vector? ");%Inputs for the Forces, one at a time
yj = input("What is the vertical component of the vector? ");
x = input("What is the x-value of the application point? ");
y = input("What is the y-value of the application point? ");
rx = x - referencex; %Finds the relative position of the vector to the reference point
ry = y - referencey;
sum_Fx = sum_Fx + xi; %Sums each vector and moment together as the loop continues
sum_Fy = sum_Fy + yj;
moment = moment + xi*ry - yj*ry;
end
fprintf("The sum of the forces is %.2f i and %.2f j",sum_Fx,sum_Fy) %Display statements for the desired information
fprintf("The moment about the reference point is: %.2f k",moment)
For some reason I am geting the result of: 180
I should be getting a result of: 280
Can you help?
  1 Comment
Image Analyst
Image Analyst on 14 Oct 2021
What were your inputs? Are you sure your equation is correct?

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by