% sweep:
clear all
clc

fs = 2000;
dt = 1/fs;
T = 2;
N = T/dt;

fmax = 10;
df = fmax/(N/2);
f = [[df:df:N/2*df],[N/2*df:-df:df]];

t = [dt:dt:N*dt];

y = zeros(1,N);
y_work = [1,0];
for n = 1:N
    y_work = [y_work(1)*cos(2*pi*f(n)*dt) - y_work(2)*sin(2*pi*f(n)*dt), ...
              y_work(1)*sin(2*pi*f(n)*dt) + y_work(2)*cos(2*pi*f(n)*dt)];
    y(n) = y_work(2);
end

plot(t,y)