In my opinion, the following code should produce a sine wave that has a frequency of $2\text{Hz}$ at $t=20$, but when I count the periods between $t=19$ and $t=20$, I count more than 3 periods. What am I doing wrong?
clear all, close all, clc;
t=linspace(0,20,10000);
y=sin(2*pi*(1+(5/100)*t).*t);
plot(t,y);
hold on;
My plot:

The argument of sine function represents the phase of the wave. In general, to find the frequency of the wave at time 't', you have to differentiate it wrt 't'.
f = (1/2*pi) * d/dt (phase).
However for the phase that linearly varies with time, i.e., frequency being independent of time, you can just divide it by 't'.
f = (1/2*pi) * (1/t) * (phase).