1

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. 
             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?

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

1 Answer 1

2

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

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.