function [matrix]=sparse_matrix(gradients,sched, d_grid, sw, yN)
t=sched(:,1)/sw;
N=yN;
fshort=-sw/2+sw/N:sw/N:sw/2;
f=ones(size(d_grid,2)*size(fshort,2),1);
d=ones(size(d_grid,2)*size(fshort,2),1);

    for k=1:size(d_grid,2)
        f((k-1)*size(fshort,2)+1:k*size(fshort,2))=fshort;
        d((k-1)*size(fshort,2)+1:k*size(fshort,2))=d_grid(k);
        
end

f=f';
d=d';


for j=1:size(sched,1)
   matrix(j,:)=exp(-1i*2*pi*f*(t(j)))/sqrt(N).*exp(-d*gradients(j));
     
    
end



end