I am writing a small matlab function to analyze data from a laser probe.
The data to be analyzed is basically: x-data: Position. y-data: Laser (light) intensity.
The sensor automatically changes the light intensity data from millivolts to arbitrary Intensity Units which go from 0 to 255. I noticed that with intense signals, the 256 range can be "rolled-over" several times.
Now, when the data rolls over just once, it is possible and easy to correct the variable overflow.
To do so, I am using this code:
Index255= find(UsefulData>=247); % On intense-enough signals, the last data before breaking the 255 cap can be relatively low. (e.g. 249,261 --> 249,6) ModeData = mode(UsefulData); % To help with discerning if data does reset from zero for In=1:1:length(Index255)-1 RegionAverage = mean(UsefulData(Index255(In):Index255(In+1))); DataQuantiles = quantile(UsefulData,10); if RegionAverage < DataQuantiles(1) % If the mean of the reigon is lower than the mode (assumed to be the base), then it's obviously under it. UsefulData(Index255(In)+1:Index255(In+1)-1)=UsefulData(Index255(In)+1:Index255(In+1)-1)+255; else continue end end
It might not be elegant, but it gets the job done (when only ONE integer overflow takes place).
However, I was not expecting a repeated variable overflow, and I am out of ideas on how to correct it.
How should this data be handled?