can someone help with this?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
- Adherence to directions;
- User-friendliness of input and output;
- Use of Matlab output functions “disp” and “fprintf” to make the output well-understandable by the script user, and
- Clear, correct and understandable input statement prompts, and
- Suppression of all unnecessary output values and
- Adequate responses so that the user understands what user actions have been incorrectly done
- Correctness of the result when I run it for my own separate test case;
- Good programming practice, including proper documentation of the completed m-file
- Good practice includes use of whitespace to make the code readable, and
- Documentation includes sufficient comment statements to
- allow a human reader to understand well the intent and method of the script and
- 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 commentaire
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!