Your data has too many artifacts to allow easy processing. You would first need to visually/manually go through your data and select chunks of it that are free of artifacts. Long periods of flat noise and large spontaneous non-periodic spikes I would consider to be artifacts. Possibly the sensor was not attached properly and the impedance was too high, possibly motor stimulation or other muscular artifacts. You can't analyze this data effectively, without more advanced techniques (like independent component analysis).
If this is EKG data, the typically preprocessing is to bandpass filter from 0.5-150 Hz, depending on your sampling rate, then notch filter the line noise (typically 50 or 60 Hz plus the harmonics). You could possibly use an sgolayfilt to remove other types of noise. You may also need to do other detrending of baseline shift.
If you need help with any of this, let us know, or search MATLAB Answers. I have personally written answers to dozens of questions regarding EKG, as well as how to do bandpass and notch filters. Search with: answered_by:"Daniel M" to get answers I have contributed.
After that, to extract the peaks and epoch the data, follow the example on this page: