LE Script permet de détecter les max d'un signal ecg
message d'erreurCode:clear all close all clc [A,B,C]=textread( 'Circu.txt',''); figure(1); ecg=plot(A,C); xlabel('temp en msec'); ylabel('tension en mV'); pic=0; MaxVal=0; tempsmax=0; rr=0; n=0; x=0; X=0; Y=0; Z=0; W=0; V=0; U=0; seuil=2; j=1; test=0; for i=1:length(A) if ( A(i)>seuil ) test=test+1; pic(test,1)=A(i); pic(test,2)=i/1000; end if ( (A(i)<seuil) & (test~=0) ) test=0; MaxVal(j)=max(pic(:,1)); x=find( pic(:,1)==MaxVal(j) ); tempsmax(j)=pic(x(1),2); j=j+1; pic=0; end end j=1; i=1; while i<=(length(tempsmax)-1) if ( (tempsmax(i+1)-tempsmax(i)) >0.1 ) W(j)=tempsmax(i); Z(j)=MaxVal(i); j=j+1; i=i+1; else W(j)=(tempsmax(i+1)+tempsmax(i))./2; Z(j)=(MaxVal(i+1)+MaxVal(i))./2; j=j+1; i=i+2; end end W(length(W)+1)=tempsmax(length(tempsmax)); Z(length(Z)+1)=MaxVal(length(MaxVal)); if (B==0) for i=1:(length(W)-1) rr(i)=W(i+1)-W(i); end else rr(1)=W(1)+B; for i=2:length(W) rr(i)=W(i)-W(i-1); end end X=rr; Y=1*60./rr; U=length(A)/1000-W(length(W)); V=[Z W]; figure(2), clf plot(A), hold on, plot(W*1000,Z,'xr') title('Détection des pics R d''un signal ECG (après correction)'); ylabel('ECG (en mV)'); xlabel('Temps (en msec)');
figure(1)Code:??? In an assignment A(I) = B, the number of elements in B and I must be the same. Error in ==> EXEMPLE at 57 rr(1)=W(1)+B;
-----