Undefined function 'ecg' for input arguments of type 'double'.

x1 = 3.5*ecg(2700).'; % gen synth ECG signal // Error in this line
y1 = sgolayfilt(kron(ones(1,ceil(NumSamp/2700)+1),x1),0,21); % repeat for NumSamp length and smooth
n = 1:Time*Fs';
del = round(2700*rand(1)); % pick a random offset
mhb = y1(n + del)'; %construct the ecg signal from some offset
t = 1/Fs:1/Fs:Time';
subplot(3,3,1); plot(t,mhb);
axis([0 2 -4 4]);
grid;
xlabel('Time [sec]');
ylabel('Voltage [mV]');
title('Maternal Heartbeat Signal');
IN THE BOLD LINE IT SHOWS THIS ERROR ,IT WOULD BE A GREAT HELP FOR ME.
PLEASE HELP

5 件のコメント

KSSV
KSSV 2020 年 11 月 23 日
Is there any variable on the name ecg?
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
Fs = 4e3;
Time = 40;
NumSamp = Time * Fs;
load Hd;
x1 = 3.5*ecg(2700).'; % gen synth ECG signal // Error in this line
y1 = sgolayfilt(kron(ones(1,ceil(NumSamp/2700)+1),x1),0,21); % repeat for NumSamp length and smooth
n = 1:Time*Fs';
del = round(2700*rand(1)); % pick a random offset
mhb = y1(n + del)'; %construct the ecg signal from some offset
t = 1/Fs:1/Fs:Time';
subplot(3,3,1); plot(t,mhb);
axis([0 2 -4 4]);
grid;
xlabel('Time [sec]');
ylabel('Voltage [mV]');
title('Maternal Heartbeat Signal');
this is the code
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
i exactly dont know about ECG function
KSSV
KSSV 2020 年 11 月 23 日
What does this file have?
load Hd;
Check does it have a variable ECG. See what
whos
gives. Does it have ECg variable.
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
load Hd;
>> whos
Name Size Bytes Class Attributes
Hd 1x1 dfilt.df2sos
i think no

サインインしてコメントする。

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 23 日

1 投票

ecg() is not a MATLAB's built-in function. You need to ask the author of the code to give you this function.

8 件のコメント

Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
Thanks for replying
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
i got the code from this link:
https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/35328/versions/1/previews/mom_and_fetus.m/index.html
Ameer Hamza
Ameer Hamza 2020 年 11 月 23 日
編集済み: Ameer Hamza 2020 年 11 月 23 日
It is from this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/35328-simulink-model-for-fetal-ecg-extraction-hdl-compatible-algorithm. You may contact its author to get the file for this function.
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
編集済み: Rehman Tanim 2020 年 11 月 23 日
Thanks for replying
i got this from the comment section :
%ECG Function file
function x = ecg(L)
a0 = [0, 1, 40, 1, 0, -34, 118, -99, 0, 2, 21, 2, 0, 0, 0];
d0 = [0, 27, 59, 91, 131, 141, 163, 185, 195, 275, 307, 339, 357, 390, 440];
a = a0 / max(a0);
d = round(d0 * L / d0(15));
d(15) = L;
for i = 1:14
m = d(i) : d(i+1) - 1;
slope = (a(i+1) - a(i)) / (d(i+1) - d(i));
x(m+1) = a(i) + slope * (m - d(i));
end
end
if yes,how can i use this?
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
編集済み: Rehman Tanim 2020 年 11 月 23 日
yeah got it ,i added this at the end of the code,now it runs
thanks for helping
Ameer Hamza
Ameer Hamza 2020 年 11 月 23 日
I am glad to be of help!!!
Image Analyst
Image Analyst 2020 年 11 月 23 日
Rehman, can you please click the link to "Accept this answer" to give Ameer credit (reputation points) for helping you? Thanks in advance.
Rehman Tanim
Rehman Tanim 2020 年 11 月 23 日
Done

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by