|
Exercise 1: Find the average of the peak values of the waveforms shown in the figure below. Run the function named 'mat01b', which generates the figure below. The function solves the equation y=x*exp(-x) for x from 0 to 9, scales it to different amplitudes 10 times, and plots the 10 scaled waveforms. The 10 sweeps are in the array named 'y' - it contains 10 columns (1 column per sweep) and 91 rows. Now open 'mat01b' in the Matlab editor (type 'edit mat01b' (without the quotes) in the Command window). Add code to the end of the function that calculates (and displays) the average of all of the peak values. Remember: the data are stored in an array named 'y' - one column per waveform, with 10 waveforms altogether. Try to do it without looking at the answer (below). Add your code, save the file, and then run it. If it doesn't work, it is the Instructor's fault.
The following code ('mat01b.m') generates the waveforms to the right. Data are stored in the array named 'y'. Exercise 2. Find the average of the peak amplitudes of the spontaneous events in the figure below. Run the function 'mat01c', which generates the figure below. This function, like 'mat01b' above, solves y=x*exp(-x), but instead of putting the results into a two-dimensional array, it just concatenates the waveforms in one row. In addition, it creates some 'jitter' in the timing, so the peaks do not occur at any fixed interval. Now edit 'mat01c'. Add code to the end of the function that calculates (and displays) the average of all of the peak values. Remember: the data are stored in an array named 'y' - which contains one row, with 10 waveforms strung out in a series.
function mat01c(varargin) Exercise 1. Run the file named 'mat01b_answer' to see the results (pictured below). This code, added to the end of mat01b, finds the average of all peaks, draws a horizontal line at this value, and labels the line with the average value.
'string',['Avg=' num2str(avg)],... 'verticalalignment','bottom') Exercise 2. Run the file named 'mat01c_answer' to see the results (pictured below). This code, added to mat01c, finds and marks the peak values and displays the average of all peak values.
'ydata',y,'color','red'); % line to show changes 'fontsize',24,'string','*') % mark peak with asterisk ['Average=' num2str(avg)],... 'verticalalignment','bottom') % label line with value |