You can esitmate the mean frequency by counting zero crossings. Depending on the level of noise in the data, you may want to do a little bit of lowpass filtering before detecting zero crossings. If your goal is to find the right frequency for timke-synchronous averaging, I think this is easier than minimizing the stadard deviation of the TSA. Demonstrate with example:
Make a signal:
y=cos(4*2*pi*f0*t)+0.05*randn(size(t));
The y=cos() includes a factor of 4 because the object has 4 corners, so it produces 4 peaks per revolution, as is seen in your original plot.
Use the measured data to estimate the frequency of revolution:
izc=find(diff(sign(y-mean(y)))==2);
f0est=(length(izc)-1)/(t(izc(end))-t(izc(1)))/4;
The division by 4 above is because the bar produces 4 peaks per cycle as it rotates.
fprintf('Est. rotation rate=%.3f rpm.\n',f0est*60)
Est. rotation rate=499.535 rpm.
This estimate of the rotation frequency is quite good. You will get a more accurate estimate by
a) sampling at a faster rate
b) interpolating to find the first and last zero crossing times more exactly
c) smoothing the noisy data (slightly) before finding zero crossings
Use this estimated frequency to calculate the time-synchronous average signal.
tCyc=mod(t,1/f0est)*f0est;
grid on; xlabel('Time (fraction of Cycle)'); ylabel('Amplitude')
The timing of the samples within each cycle is not exactly the same, from one cycle to the next. Thererfore, if you wish to estimate standard deviation at various times throughout the cycle, you make want to interpolate to a common time-within-the-cycle.