PHYSICS 241 -- Assignment 6 -- Due Wednesday 10/10 at midnight. ============================================================================== Now problems 4-10 to 4-15 in Rev 1.47 and up RS6-0) NOTE: Whenever a figure is requested, the figure should be submitted as a .bmp, .png, .jpeg, or .eps along with the script. All figures should have titles and axes should be labeled. Title font should be at least 18 point and axis label font 14 point. Your name should appear on each figure (use the gtext or the text function to add your name). RS6-1) Write a Matlab script and a function that integrates data between two times Assume that you are given a data file of accelerations and times, and that the times are equally spaced. Your function should work on a data file of arbitrary length. Label your axes and include a title for your figure. [Use The file acceldata1.txt] Submit a picture along with your script. The header of the function is as follows: function [I]=integral(x,limit1, limit2) % x is an array containing the function evaluated at n points. % equally spaced between lim1 and lim2 (including lim1 and lim2) RS6-2) Having integrated once to get velocity, run your data through the derivative function you likely wrote to solve earlier problems and show (by plotting the acceleration data vs. the integrated and differentiated data) that you recover the original acceleration data. Submit a picture along with your script. RS6-3) Now that you know your integral function works correctly, from the provided accelerations, integrate once to get velocity and again to get position and plot the three graphs (using subplot) stacked one above the other using the same time axes. Submit a picture along with your script. RS6-4) In previous problems you worked with simulated acceleration data File AccelerometerY_raw.dat contains data from a real accelerometer mounted inside a truck driving around the campus of our school. Load the data and plot acceleration vs. time, velocity vs. time and position vs. time on three vertically stacked plots using subplot command. Plot time in seconds, acceleration in m/s^2, position in m and velocity in miles per hour. If you do it right, you will see that the final speed of the truck approaches 100 mph, considerably in excess of the campus speed limit. We will examine this artifact in the next questions. You will note that the acceleration data is noisy, but that integration to get velocity and position removes the noise. NOTE: Matlab will at first fail to read your data file because of the comments (metadata) at the top. Put a % sign in front of each comment and then Matlab WILL read the data file. Submit a picture along with your script. RS6-5) Let us correct the 100 mph truck. Accelerometers can have offsets, meaning they measure a non-zero acceleration when there should be a zero acceleration. This is not uncommon for sensors, and the data analyst must calculate and remove this offset. You can do this by eye using the data cursor, but here is an automated approach. Write a function called segmented_offset. function [offset] = segmented_offset(data,n) % segmented_offset.m -- The idea is to find an offset for data. % Data is assumed to contain periods of variation (acceleration) % As well as relatively quiet periods (vehicle at rest). The median value % of the quiet periods is a good "offset". % Thus function breaks data into n segments arranged by time % If n=5, then first segment would be first 20% of data, t % the 2nd segment is next 20%, the 5th segment the last 20% of data. % I generally recommend n=10. % This must mean the waveform is "quiet" for at least 10% % of the time -- and this quiet period will be found and its median % reported. % USAGE [offset] = segmented_offset(V,10); % V=V-offset Hint, 1) Make arrays of length 'n' for median and std. 2) Set up a "for" loop that cuts the data into n sections and calculates median and std of each section (and plugs results into median and std arrays). 3) Use the min function to return not just the minimum value but the index of the section in which it occurred. 4) Select the median value for that section with the minimum std and return it as the offset. RS6-6) Rewrite 6-4 to use the segmented_offset function to fix the acceleration data. Now your plots of accel, velocity and position will make more sense, and you will see that the truck never exceeded 30 mph on campus! It also only traveled about 200 meters. PHYSICS 241 -- Assignment 7 -- Due Monday 10/15 in class. ============================================================================== Read Chapter 5, focusing on sections 5.5 to 5.7. Do the following problems. All of these are paper and pencil. We resume programming in Assignment 8. Problem 1, 8, 10, 11, 12, 13. PHYSICS 241 -- Assignment 8 -- Due Monday 10/22 at midnight. ============================================================================== Read the rest of Chapter 5. Problems: Chapter 5: #3, 4, 5, 6, 7, 9, 14, 15 Note, problem 15 is not in the printed version of the book. Here it is. Problem 5-15) In problem 5-12, you solved for vx(t), vy(t), x(t) and y(t) analytically. However in HW6, you wrote an integration function. Use your analytical solutions for vx(t) and vy(t) and generate a table of vy(t) and vx(t) data. Plug time and v into your integration function to arrive at x(t) and y(t). Plot the graphs of x(t) vs y(t) so obtained with the results you determined analytically and plotted in problem 14. The two methods should agree.