combining 2 ECG signal into 1

4 views (last 30 days)
I'm tring to merg 2 ECG signal into one (with same sampling rate), however, at the merging point, there is some error. I can't figure it out. could someone please help, appreciated. my code and the figure are attached.
clear all
close all
dataaf=load("AF2.mat"); % AF signal
xaf=dataaf.val(1,:);
xaf=detrend(xaf)';
datan=load("normal2.mat"); % Normal
xn=datan.val(1,:);
xn=detrend(xn)';
%xnr=resample(xn,250,128); % resample raw signal
xc=[xn;xaf];
Fs = 128;
t = (0:length(xc)-1)/Fs; %time value of any sample = [sample no./Fs]
plot(t,xc)
xlabel('Time [s]')
% hold on
pause

Accepted Answer

Star Strider
Star Strider on 26 May 2022
Unless the row vectors ‘xn’ and ‘xaf’ have the same number of elements, the vertical concatenation to produce ‘xc’ is going to fail:
xc=[xn;xaf];
Horizontrally concatenating them (note the substitution of the comma for the semicolon) however will work:
xc=[xn,xaf];
.
  4 Comments
Star Strider
Star Strider on 6 Jun 2022
As always, my pleasure!

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!