Unable to perform assignment because the left and right sides have a different number of elements.

2 次查看(过去 30 天)
I am calculating first and second derivative for getting threshold values for ecg. but getting error. Please help.
for n=5:numel(ecgBR)
ecg_dif(n)=abs(ecgBR(n,1)-ecgBR(n-2,1));
ecg_dif2(n,1)=abs(ecgBR(n,1)-2*ecgBR(n-2,1)+ecgBR(n-4,1));
end
ERROR:Unable to perform assignment because the left and right sides have a different number of elements.
ecgBR=1X3600 double matrix

采纳的回答

Image Analyst
Image Analyst 2020-9-12
Since ecgBR has only one row, not n, you cannot do ecgBR(n, 1), which is the nth row in column 1. But you have 3600 columns, not 1, and 1 row, not 3600. Get rid of the ,1:
for n=5:numel(ecgBR)
ecg_dif(n)=abs(ecgBR(n)-ecgBR(n-2));
ecg_dif2(n)=abs(ecgBR(n)-2*ecgBR(n-2)+ecgBR(n-4));
end
  2 个评论
ekta yadav
ekta yadav 2020-9-13
*Thanks @Image Analyst. It worked. Really saved lot of time of mine.
*I am facing one more problem while detecting peaks of ECG. Please help
[pks3,locs_R2] = findpeaks(ecgBR,'MinPeakHeight',0.6,'MinPeakDistance',200); %R peakes
ecg_inv=-ecgBR;
[pks2,locs_S] =findpeaks(ecg_inv,'MinPeakHeight',0.4,'MinPeakDistance',200); %S peaks
[~,min_locs] = findpeaks(ecg_inv,'MinPeakDistance',19); %Q peaks
locs_Q = min_locs(ecg_inv(min_locs)=>0.12 & ecg_inv(min_locs)=<0.3);
*I got this code from internet. its detecting R and S peaks but not Q peaks. Please suggest the corrections.

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by