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. Raw data

Now, when the data rolls over just once, it is possible and easy to correct the variable overflow. enter image description here

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. 

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?

  • not as 8-bits data - that is for sure Jul 2 '15 at 13:01
  • Look for the difference between points. If its greater than a threshold +/- 255
    – Ewan
    Jul 2 '15 at 13:33
  • 2
    We're going to need a bigger integer.
    – user22815
    Jul 2 '15 at 13:34

I solved it. Again, it does not look elegant, but gets the job done.

while h<length(UsefulData)
       if abs(UsefulData(h)-UsefulData(h+1))>190
           plot(UsefulData(h-100:h+300), '-r'), hold on
           plot(101,UsefulData(h),'*','MarkerEdgeColor','b'), hold off

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.