User Tools

Site Tools


gibson:teaching:spring-2016:math445:lecture:interpolation

Math 445 lecture 23: finding a frequency by interpolation

The following example shows how to use interpolation on discretized data to estimate the frequency of an oscillation.

% Find the frequency of f(t) = -sin(omega t) by interpolation.
 
% choose some fixed value of omega, then generate f(t) = -sin(omega t).
omega = 0.87;       
 
t = linspace(0,10,20);
f = -sin(omega*t);
 
% plot f(t)
plot(t, f, 'bo-');
grid on
xlabel('x')
ylabel('f(t) = -sin(omega t)')
 
% get index n of first crossing from f positive to f negative
n = find( f(1:end-1)> 0 & f(2:end) < 0);
 
% interpolate t value of f(t) = 0 using data near that zero crossing
T = interp1(f([n n+1]), t([n n+1]), 0);
 
omega
omega_estimated = 2*pi/T
gibson/teaching/spring-2016/math445/lecture/interpolation.txt · Last modified: 2016/04/29 11:56 by gibson