Lesson 5: More Formulae
Basic Data Filtration
Today's Lesson
Filtering Data with MatlabRoot Means SquaredButterworth Filters
Basic Statistical Analysis of DataMean, Mode, MedianStandard DeviationCross Correlation
Root Means Squared
• When used with a sliding window, smoothes data.
• RMS = sqrt(sum(all x^2)/n)
Using Root Means Squared
RMS With a Sliding Window
Filtering Data
Goal of removing unwanted frequencies from signal data.
Butterworth filters produce no ripple, but slowest roll-off.
Elliptical filters produce steepest roll-off, but ripples in the pass and stop band.
Typically, Butterworth Filters are the Filters of Choice.
Different Filters
Creating a Butterworth Filter
Effect of Order on the Filter
Rectification of Data
Abs absolute value function
Statistical Functions
Mean, std, xcorr
Programming Tips: Error CatchingA program's Achilles Heel is unexpected data: Extra Data Missing Data Wrong Data Type
It is easy to protect your programs from these sorts of errors by adding data checking loops.
Example: Array Length Check
%Imagine that for this function, we know that there %should be only two numbers in the input array.
function[sum] = addThemUp(summands)
%If there aren't 2 numbers in the array, exit nicely. if(length(summands) ~= 2) disp('There weren't exactly 2 numbers in the input.') return; end
sum = summands(1) + summands(2);
Example: Data Type Check%Now, let us add something to the previous function to %further ensure that it will work.
function[sum] = addThemUp(summands)
%If there aren't 2 numbers in the array, exit nicely. if(length(summands) ~= 2) disp('There weren't exactly 2 numbers in the input.') return; end %If one of the 2 "numbers" isn't a number, exit nicely. if(~(isnumeric(summands)) disp('One of the summands was not a number.') return; end
sum = summands(1) + summands(2);