Convert ECG signal waveform into text file

Hi.
I want to ask is it possible to convert ECG signal waveform into text file? And if it is possible how to perform it?
I am able to load the ecg data file in .mat file from database and processed it through according to the matlab code written.

Answers (1)

Steps:
%load the mat file
data=load('mat_file.mat');
%Save the data in txt file
dlmwrite('filename.txt',data)

9 Comments

Thank you for the reply sir.
However, the second command to save the data in txt file, error as follow popped up:
Undefined function 'real' for input arguments of type 'struct'.
Error in dlmwrite (line 181)
str =
sprintf('%.*g%+.*gi',precn,real(m(i,j)),precn,imag(m(i,j)));
Can you attach a sample ECG mat file?
%load the mat file
data=load('mat_file.mat');
%Save the data in txt file
dlmwrite('filename.txt',data.val(:))
The (:) will force it to write one value per line; the current data is a row of data values.
The .mat has successfully converted into .txt. Thank you sir for your help.
If I may ask sir, the data values written in the .txt file reflect which waveform? Is it the R peak only or all the points of the ECG signal?
Sir @Walter Roberson @KALYAN ACHARJYA, how can we distinguish datapoints of the x and y axis of the waveform. I mean it only have the amplitude value of the waveform. How can we know the x axis value (time (s)) corresponding with the y axis value (amplitude)?
How to convert with both values and time?
time = (0:length(val)-1)/Fs;
Here Fs needs to be the sampling frequency, in hertz (cycles per second.)
Nothing in the .mat file has information about the sampling frequency; you cannot deduce it from the data itself. You would need to find it as external information.

Sign in to comment.

Products

Release

R2019a

Asked:

on 2 Mar 2021

Commented:

on 11 Mar 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!