필터 지우기
필터 지우기

The code works but the values don't match and I can't find the error

조회 수: 5 (최근 30일)
Inês Silva
Inês Silva 2023년 1월 19일
이동: Walter Roberson 2023년 1월 22일
The code is the following and its objective is to obtain the coordenates of peaks od the signal FINAL whose graphic is attached.
However the values don't match and I can't find the problem .
Can someone help?
clear
clc
ID = 1;
sinal = read_ecg_txt (ID);
Unrecognized function or variable 'read_ecg_txt'.
filtrado = remove_noise(sinal,101);
FINAL = Remove_noise2(filtrado,20);
k = 500;
limiar = 300;
L = length(FINAL);
Picos = [];
a = (k-1)/2;
t = 1;
for i = 1:k:L
if i<(ceil(a))
for q = 1:k
maximo = 0;
if FINAL(q) > maximo
maximo = FINAL(q);
M = q;
end
end
Picos(t,1) = maximo;
Picos(t,2) = M;
t = t + 1;
elseif i>(L-(floor(a)))
for q = (L - k):L
maximo = 0;
if FINAL(q) > maximo
maximo = FINAL(q);
M = q;
end
end
Picos(t,1) = maximo;
Picos(t,2) = M;
t = t + 1;
else
for q = (i-(ceil(a))):(i + (floor(a)))
maximo = 0;
if FINAL(q) > maximo
maximo = FINAL(q);
M = q;
end
end
Picos(t,1) = maximo;
Picos(t,2) = M;
t = t + 1;
end
end
m = 1;
Peaks = [];
for p = 1:(t-1)
if Picos(p,1) > limiar
Peaks(m,1) = Picos(p,1);
Peaks(m,2) = Picos(p,2);
m = m + 1;
end
end
  댓글 수: 2
Inês Silva
Inês Silva 2023년 1월 19일
Also the variables ID, k and limiar are supposed to be inputs , for rigth now I'm just having them as fixed values since is easier to try and find the problem that way
Inês Silva
Inês Silva 2023년 1월 20일
The problem is that I can't use max

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 1월 19일
이동: Walter Roberson 2023년 1월 22일
read_ecg_txt() remove_noise() Remove_noise2() are missing
for q = 1:k
maximo = 0;
if FINAL(q) > maximo
maximo = FINAL(q);
M = q;
end
Resetting maximo = 0 each iteration of the loop is suspicious.
Consider using
[maximo, M] = max(FINAL(1:k));
with no loop.
  댓글 수: 1
Inês Silva
Inês Silva 2023년 1월 20일
이동: Walter Roberson 2023년 1월 22일
But thank you , because of your comment about the fact that the maximum was resetting with ever loop interation, which was something I hadn't realised , I managed to find and fix the problem.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Single-Rate Filters에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by