# Sine-wave phase-dependent event?

A sinusoidal wave with frequency $$f$$, angular frequency $$\omega = 2 \pi f$$, amplitude $$A$$ and phase $$\phi$$ is of the form: $$A \sin(\omega x + \phi)$$

an example with in MATLAB:

T = 5000;         % Total time in ms
dt = 0.04;        % Integration time step in ms
nt = round(T/dt); % Time steps

A = 5;
f = 1;
omega =  2*pi*f;
phase = 0;

x = (1:1:nt) * dt/1000;
y = A * sin(omega*x + phase);

plot(x,y)


I am doing a loop as for i=1:1:nt and would like to do something every $$k$$ iterations. I would like $$k$$ to depend on the phase of the wave, so that if I change the frequency $$f$$, the function is applied at the same part of the curve, regardless of the frequency. Can you define $$k$$ in terms of the iterate i?