Search for question
Question

Question 2 - File I/O and plotting. [13 Marks] 2.1 The file human_motion_data.csv contains some motion capture data of a subject's right arm undertaking some exercises. Open the file to have

a look. It has some header information and then contains 22 columns of data, the 1st column is the frame number, then the following nine columns are associated with a lab coordinate system and can be ignored. There are then 12 columns of data that represent the 3D positions (x, y and z) of the shoulder, elbow, wrist and hand respectively. Create three new matrices, shoulder_position, elbow_position and hand_position. These matrices should each contain 3 columns of x, y and z data for each marker respectively. [2 marks] 2.2 We want to know the length of the subjects arm. To do this you should use the first row of data. Determine the length of the upper arm (distance between shoulder marker and elbow marker) and assign to a variable upper_arm_length and then the length of the lower arm (elbow to hand) and COMPUTERS IN ENGINEERING ANALYSIS Assessment Paper 2024 MECH101001 Page 3 assign to a variable lower_arm_length. Assign the sum of the two values to a variable arm_length. All three should be scalar values. [3 Marks] 2.3 You have been given a user-defined function (UDF) named reach_calculator.m. Open this and read the code and comments to understand what the UDF does. Now using a for loop and the UDF, create a column vector, arm_reach, that has a value for each sample (row) of collected data. [2 marks] 2.4 If the data is recorded at 40Hz, create a column vector named exercise_time that has the same number of rows as arm_reach and contains the time in seconds at each sample, starting at 0.0sec. [1 mark] 2.5 Now determine, for each value of arm_reach, what percentage of the arm_length has been achieved (a value of 100% would signify that the arm at that point is fully extended). The result should be a column vector called percentage_reach. [1 mark] 2.6 A figure window has been created. In the figure window place two subplots in the format of one row, two columns of axes. In the first of the axes plot the hand_position from question 2.2 against the exercise_time vector. Three lines should be visible. Label appropriately and include a title. In the second axes plot the percentage_reach against exercise_time. Again, label appropriately and include a title. [4 markel assigmont filo I nood to do 01. 232 45 and 6 only

Fig: 1