Two type of calculating R in steepest-descent modeling algorithm I have wrote this algorithm for steepest descent:

function [e2,w_opt]=SteepestDescent_Alg2(x,d,itr,w)
N=length(w);
sample=length(x);
x=[zeros(N-1,1); x];%padding

x1=zeros(sample,N);
for i=1:N
    x1(:,i)=x(N-(i-1):end-(i-1));
end

R=x1'*x1/sample;
P=x1'*d/sample;
lambda=eig(R);
mu=1/(min(lambda)+max(lambda));

w_opt=zeros(size(w));
dd=(d.'*d)/(sample);
e2=zeros(1,itr);
for i=1:itr
   grad=2*R*w_opt-2*P;
   e2(i)=dd+w_opt'*R*w_opt-2*P'*w_opt;
   w_opt=w_opt-mu*grad;

end
wc=R\P
end


These lines forming R:

x1=zeros(sample,N);
for i=1:N
    x1(:,i)=x(N-(i-1):end-(i-1));
end
R=x1'*x1/sample;


But if we use other way to calculating R:

function R=corlnm2(h,N)
    %This function obtains the correlation matrix of the output
    %of an FIR filter which is derived by a white noise, and its
    %coefficients are given in vector "h".
    %"N" specifies the dimensions of "R".
    %
    %   R=corlnm2(h,N)
    %j=sqrt(-1);
    a=size(h);
    if a(1)&gt;a(2)
       h=h';
    end
    m=length(h);

    for k=1:N
        if k&lt;=m
            R(k)=h(k:m)*h(1:m-k+1)';
        else
            R(k)=0; 
        end
    end
    R=toeplitz(R);
end


The code have written for this problem, also assume there is coloring filter with tap numerator coefficient of h:



Both two way of estimating R, getting value, really close together, but the second way gives weird learning curve.
Also the input noise set to 0.1 variance, thus minimum kesi(Mean Square Error) must be 0.1, calculating R in first manner give correct learning cure(plot of MSE vs itteration) but the W's are extremely close to Wo
even with more than 0.001 precision, why? And I think both way must give same answer why but this isn't ...?
So let's have a look at your calculations:

x1(:,i)=x(N-(i-1):end-(i-1));


Let's say N = 10 and sample = 100 so that end = 110.

For i=1 that means we sum from 10 to 110.

For i=2 that means we sum from 9 to 109.

etc.

Comparing that with:

R(k)=h(k:m)*h(1:m-k+1)';


where m is the same as sample:

For k=1 that means we sum from 1 to 100.

For k=2 that means we sum from 2 to 99.

I think all that's happening is your first calculation is assuming x is zero-padded and the second one is assuming that it's not.

That there are differences between the two is hardly surprising, given that they are summing different (possibly random) values.