You are here

Week 3: Dead ends and old functions

This week mostly consisted of figuring out how to write the most difficult part of the code.  The problem sounds relatively straightforward.  Find the flat areas of each time series plot to get base, sample and calibration measurements.  Use MATLAB algorithms to find these more consistently and faster than a human. 
The first part was quite simple.  It takes the derivative of the data and filtered it, then set thresholds of slope to get relatively flat areas.  It then creates a logical array of the same dimensions as the original data, where 1 (true) is a 'good' point, and 0 (false) is a 'bad' point where a plateau does not exist.  
The next part, finding the actual locations of the measurements, was more difficult.  I floundered around for a while with iterative process involving while loops.  It worked...in my head...but not in MATLAB.  I spent some time debugging until I took a break and looked at an old project from freshman year.  I found two image processing built in functions, bwlabel and regionprops, that I applied to the time series data.  
I currently have code that stores information about each region in structs to be called later.
The selection is based on nested switch cases.  The trick will be considering every possibility of where the measurements are located for each switch case and writing a routine for each case.  That will keep me busy the next few days.