+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Newbie level 1
    Points: 15, Level: 1

    Join Date
    Nov 2016
    Posts
    1
    Helped
    0 / 0
    Points
    15
    Level
    1

    Base drift removal of ecg

    Code vb.net - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    clear;
    system('rdsamp -r e0801 -f 17.3 -l 10.0 -p > e0801.txt');  % jump 17.3 seconds, read 10 seconds
    [t,y(:,1),y(:,2)] = textread('e0801.txt','%f %f %f');      % read time and voltages from file
    fs = 1 / (t(2) - t(1));                 % sample rate, hertz
    period = 0.96;                          % cardiac period, seconds
    N = length(y);
    t = (0 : N-1) / fs;
    for n = 1:2                             % for each voltage waveform
      subplot(4,1,n*2-1); plot(t,y(:,n)); xlim([0 max(t)]);
      title('Input Data','FontWeight','bold'); xlabel('Seconds'); ylabel('Millivolts');
      xlim1 = xlim;  ylim1 = ylim;          % remember plot limits
      %
      % Subtract baseline drift. See [url]http://www.dataq.com/applicat/articles/an14.htm[/url]
      z(:,n) = y(:,n) - smooth(y(:,n),round(fs*period));
      subplot(4,1,n*2-0); plot(t,z(:,n)); xlim([0 max(t)]);
      title('Subtract Baseline Drift','FontWeight','bold'); xlabel('Seconds'); ylabel('Millivolts');
      xlim(xlim1);
    end;

    for above code getting this error

    init: can't open header for record e0801
    Attempted to access t(2); index out of bounds because numel(t)=0.

    Error in ecgdat (line 4)
    fs = 1 / (t(2) - t(1)); % sample rate, hertz


    plz help
    Last edited by BradtheRad; 27th November 2016 at 06:46. Reason: Added code formatted window

    •   Alt27th November 2016, 04:08

      advertising

        
       

  2. #2
    Super Moderator
    Points: 22,935, Level: 36
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Portugal
    Posts
    6,969
    Helped
    853 / 853
    Points
    22,935
    Level
    36
    Blog Entries
    5

    Re: Base drift removal of ecg

    Why don't you debug the line which precedes the error on line #4, such as plotting the content of the variable 't' to check if the text was realy read from file, and also to see if its content was correctly allocated on the matrix ? In addition, if the above was wrote in MATLAB, shouldn't the calculation on line #7 have been made with the dot division matrix operator (./) ?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



--[[ ]]--