Description

Attached Files: File acc.mat (2.045 KB) (Assignment 4.1) Create M-file that reads the attached data file (acc.mat) and find the best fitting polynomial equation. In this assignment you will learn how to curve fit realistic sensor data. Here are the hints for your assignment. You should first copy the acc.mat into your matlab folder. >> load acc This will load 3 variables – Measured acceleration (acc_measured), Real acceleration (acc_real) and time t. acc_measured is acc_real + noise from sensors (1) Using figure and plot command, plot sensor data (acc_measured) as a red start (e.g., plot(x,y,’r*’) and real theory value (acc_real) as a line. You must show both on the same plot to compare it. Title your figure and legend properly assuming that you are copying this plot into your engineering report. (2) Using polyfit command, find the best 4th order polynomial equation for the noisy sensor data. Hint: >> p=polyfit(t,acc_measured, 4) (3) Plot sensor data, real value and the fitted 4th order polynomial equation on the same plot, using polyval(p,t) command. You can learn how to use polyfit and polyval by typing >> doc polyfit >> doc polyval or by looking referring to my lecture slide page 10. (Assignment 4.2) Create M-file that generate xy grid, and plots the 3D surface, z=sin(3*x).^2.*cos(4*y)^3, where x and y ranges from -pi to pi. Create title and axis, color properly. Hint: Use linspace command to create xy grid, use surf(x,y,z) to plot it in 3D. Refer to my lecture slide p17.