I sample a zero to 400Hz varying pulse train at 4kHz and post-process this pulse train data by MATLAB to obtain each single pulse's period. So for instance below represents a 0 to 6V pulse. The green line is the mid point 3V. So in MATLAB I find the first sample point which crosses up the mid voltage green line and the consecutive sample point which crosses up the green line. These points are shown in red dots. So the time distance between these two red dots gives me the period of that particular pulse. That is how I calculate each pulse period from the logged data.
My question is how can I estimate the error due to sampling rate? Imagine The pulse is 400Hz and sampling rate is 4kHz; and if I increase the pulse sampling rate up to 8kHz how does the accuracy change?
And if I measure and know the actual rise time of the pulse as 2μs, how can I relate the sampling frequency I will use to the pulse period measurement accuracy?