ROS=[100 150];
x=0:5:3000;%00;
results=zeros(80,3);


for ro=2%:2
    RO=ROS(ro);
    for lam=8%3:80
        lambda=lam*25;
      
        y=cos(2*pi*(1/lambda)*x);
        
        
        x_grid=RO:70:2500;%00;
        w_tot=zeros(1,length(x_grid));
        w_by_y_tot=zeros(1,length(x_grid));
        y_corrected=zeros(1,length(x_grid));
        
        for i=1:length(x)
            xmin1=x(i)-RO;
            xmax1=x(i)+RO;
            u=find(x_grid>=xmin1 & x_grid<= xmax1);
            xmin=min(u);
             xmax=max(u);
                     
            for j=xmin:xmax
                dist=abs(x_grid(j)-x(i));
                
                if dist <= RO
                    w=(RO^2-dist^2)/(RO^2+dist^2);
                    w_tot(j)=w_tot(j)+w;
                    w_by_y_tot(j)=w_by_y_tot(j)+w*y(i);
                end
            end
        end
        
        for jj=1:length(x_grid)
            if w_tot(jj)==0 
                y_corrected(jj)=NaN;
            else y_corrected(jj)=w_by_y_tot(jj)/w_tot(jj);
            end
        end
        plot(x,y)
        hold on
        plot(x_grid,y_corrected,'r')
        hold off
        results(lam,ro)=abs(min(y_corrected));
    end
   
    end
% results(:,3)=results(:,2)./results(:,1);
 results=[(25:25:2000)' results];