Measurements out of sync

Hi everyone, pardon my bad english,
Currently, i’m working on an acquisition that needs fast measurements.
The arduino’s ADC is doing a measurement in 0.05 s, and each set has 40 measurements that needs to be in a specific order.
I open the serial in matlab interface, however after a number of sets, the measurements comes out of sync.
I wonder if anyone in the community has experienced that before, so you can help.

I attached the figure of a measurement set. The first one is the correct measurements and the second is the measurements out of sync.

Thanks in advance.

Where's your code, schematics, and other project details?

Do explain in detail what you mean with "out of sync". What is out of sync with what? By how much? Is it a constant or changing/increasing/decreasing "out of sync"?

Some explanation of what those wild graphs actually try to show would be useful.

measurement number 1 becomes measurement number 38

If each measurement comes with a label or ID number, that can't happen. Better yet, each measurement should have a time stamp.

A quick look at your graphs suggests the one issue is the input is changing too fast for your sample rate.

And I would guess the samples are not "triggered" by the input signal so they look out of sync.

I suggest you draw an example of what you are expecting your input to be. Then see how many points (samples) you require to make your data useful.