To find the DC value of a vector in Matlab without knowing its sampling rate, you can simply use the mean
function to calculate the average of all the values in the vector.
main.m69 chars6 lines
The mean
function calculates the sum of all the elements in the vector and divides it by the number of elements in the vector, giving you the DC value.
If you have a signal sampled at a certain rate and you want to find the DC value of a portion of that signal, you can use the dcblock
function to remove any AC components in the signal and then calculate the mean.
main.m201 chars8 lines
The dcblock
function, available in the Signal Processing Toolbox, removes any DC offset in the signal by high-pass filtering it with a cutoff frequency of 0.005 Hz, and outputs the filtered signal.
gistlibby LogSnag