I realized that the pause we provide to the code to acquire EMG data should be equal to the
emg.NotifyWhenDataAvailableExceeds / emg.Rate
which means 400/ 4000 = 0.1 not 0.01
Otherwise this multirate signal sampling happens.
while 1
% check the existing time.mat file
time(end + 1 : end + 1, 1) = str2double(datestr(now,'SS.FFF'));
% ---------------------This value should be 0.1.-------------------------------
pause(0.1); % this pause should be there to acquire EMG data
if (getGlobalSx==0) % if new set of data is available
data = getGlobalx; % aquire data
setGlobalSx(1);
end
raw(end +1:end+400, : ) = data;
end