Search for question
Question

Question 4 - Loops and logic [9 Marks] 4.1 Open process_power_data.csv to see what the data looks like. Extract the columns specified by headers 'Time (sec)', 'Estimated Power (W)' and 'Measured

Power (W)'. Assign to variables sample_time, estimated_power and measured_power respectively (all should be column vectors). [2 marks] 4.2 There is an error noted in the measured_power data. At one point in the data there is an unexpected drop to zero for a number of samples. This only occurs once in the data set. Programmatically find the index of the first zero in measured_power and assign to a variable zero_start. Do the same for the last zero value and assign to a variable zero_end. This must be done using either a for or while loop. [3 marks] 4.3 Remove the section of zeros from measured_power and also the corresponding rows from estimated_power. Assign to the variables adj_measured_power and adj estimated_power respectively. Ensure that the values of measured_power and estimated_power remain unchanged from question 4.1. [2 marks] COMPUTERS IN ENGINEERING ANALYSIS Assessment Paper 2024 MECH101001 Page 4 4.4 Now we want to remove an appropriate number of rows from the sample_time vector. The time still wants to run from 0.0 and should go up in steps of 0.2sec and needs to be the same length as adj_measured_data. Set to a variable adj_sample_time. [1 mark] 4.5 The estimated power is predominantly higher than the measured power. Find the average percentage error between the adj_estimated_power and adj_measured_power and set to a value percentage_error. [1 mark]

Fig: 1