This bachelor thesis aims to solve problems of ECG signals, respectively detection of QRS complex and P wave, and subsequent analysis of heart rate variability. The first part is focused on literary research. It deals with the heart anatomy, electrocardiography and more detailed description of individual waves, as well as with the pre-processing of ECG signal, QRS complex detection and P wave detection. The last theoretical part describes the analysis of heart rate variability. In the practical part detection of QRS complex, P wave and subsequent analysis of heart rate variability is programmed in MATLAB. Finally, statistical evaluation is performed in STATISTICA