In the hereby work, we present the use of sparse representation and overcomplete dictionary learning method for examining the case of anomaly detection in an electrocardiographic record. The above mentioned signal was introduced in a form of correct electrocardiographic morphological structures and outliers which describe different sorts of disorders. In the course of study, two sorts of dictionaries were used. The first consists of atoms created with the use of differently parameterized analytic Gabor functions. The second sort of dictionaries uses the modified Method of Optimal Directions to find a dictionary reflecting proper structures of an electrocardiographic signal. In addition, in this approach, the condition of decorrelation of dictionary atoms was introduced for the sake of gaining more precise and optimal representation. The dictionaries obtained in these two ways became a basis for the analyzed sparse representation of electrocardiographic record. During the anomaly detection process, which was based on decomposition of the analyzed signal into correct values and outliers, a modified alternating minimization algorithm was used. A commonly accessible base of data of electrocardiograms, that is MIT-BIH Arrhythmia Database, was utilized to examine the conduct of the recommended method. The effectiveness of the solution, which validated itself in searching of anomalies in the analyzed electrocardiographic record, was confirmed by experiment results.