BIE103 Introduction to Bioengineering - Matlab Assignment - The University of Sheffield, UK
a) See worksheet 3 for plotting.
b) Worksheet 5 overviews 'for loops.' The solution to question 2, worksheet 5, will help how to specify the starting and end values of the loop.
c) Application of script written in (b).
d) Application of script written in (b) and plotting (worksheet 3).
e) See worksheet 6. Even if you have difficulty with this, some marks are available for comments and error checking.
f) This is similar to the solution for identifying zeros in worksheet 5. Note depending how you choose the threshold value, you may have multiple data points on each maximum that exceed the threshold. To identify the specific point which corresponds to the maximum, a more sophisticated conditional statement is needed involving 'AND',' >' and '<'.
TIP: Think about the conditions a maximum point must satisfy in relation to the magnitude of points immediately before and after it. Compare, e.g. data(i), to the points immediately before (data(i-1)) and immediately after (data(i+1)) using > or <.
g)
i) The cycles are not of equal length so a strategy to average them requires aligning all the cycles about the locations of their maximum (identified in (f)). This builds on worksheet 2 and understanding how to structure (and refer to) data in a matrix.
As an example, suppose we had a vector v and the 1st and 2nd peaks were located at the array entries v(52) and-v(100). The cycle length would be distance between peaks, i.e. 100-52=48.
To align the data in a new matrix 'MatCyc' where each row of MatCyc corresponds to 1 cycle:
We could think of 1 cycle as going from i=52-a to i=52 +b where a+b=48 (cycle length) and the next cycle going from i=100-a to i=100+b where a+b =48. So,
MatCyc(1,:):=data(52-18:52+30)=data(34:82) (1st row of the matrix MatCyc)
MatCyc (2,:)=data(100-18:100+30)=data(82:130) (2nd row of the matrix MatCyc)
Note we have organised the data so that the peaks of the 1st and 2nd rows occur in the same column location of the matrix 'MatCyc'. Hence if we average the rows, we would obtain an average cycle.
ii) Application of the Matlab command 'mean'. Use the Matlab help command for 'mean', i.e. 'help mean', to see format of inputs.
iii) Plotting (worksheet 3). Note if you end up with multiple peaks after averaging it means your method for aligning the peaks of your cycle wasn't correct.
h) Repeat (f) and (g) for the ecg50hz signal. This should be quick to do if you have written scripts for f) and g) as you are just applying them to a different dataset.