For loop 大矩阵的自相关

For loop 大矩阵的自相关,for-loop,indexing,For Loop,Indexing,我对Matlab相当陌生,正在尝试计算一个大向量场的自相关系数。基本上,我有一个15x13664矩阵,在这里,我想分别计算每列的自相关,时间滞后到第1列的长度。我能够使用2个for循环计算1列的自相关,但在让Matlab转到下一列时遇到了困难。我想将信息存储在一个矩阵中,该矩阵将每个自相关作为矩阵中的一列(即,我的输出应为14x13664 matirx)。我的代码如下: b=1;%Start with column 1 for b=1:3,%Compute autocorrelation for

我对Matlab相当陌生,正在尝试计算一个大向量场的自相关系数。基本上,我有一个15x13664矩阵,在这里,我想分别计算每列的自相关,时间滞后到第1列的长度。我能够使用2个for循环计算1列的自相关,但在让Matlab转到下一列时遇到了困难。我想将信息存储在一个矩阵中,该矩阵将每个自相关作为矩阵中的一列(即,我的输出应为14x13664 matirx)。我的代码如下:

b=1;%Start with column 1
for b=1:3,%Compute autocorrelation for first 3 columns
    N=15;%Total number of points in each column
    i=1;%set up variable for loop
    j=1;
    k=1;
    m=0;%time lag variable
    for index=1:15 % run autocorrelation 15 times
        L=15-m;%Stop multiplying u velocity once end is reached
        for index2=1:L,
            multiply(i,b)=Utest2(i,b).*Utest2(j+m,b);%Multiply fluctuating velocity by itself plus  time lag
            i=i+1;
            j=j+1;
        end
        Average(k,b)=sum(multiply(:,b)/N;%Find the average using number of points in multiply
        correlation(k,b)=Average(:,b)./(stdU.^2);%Find correlation
        m=m+1;%increase time lag
        index2=1;%Reset loop
        i=1;
        j=1;
        k=k+1;
        N=N-1;%Reduce number of point in multiply for each iteration
    end
    b=b+1;
end
我得到一个错误: 下标赋值维度不匹配

我不明白Matlab为什么不转到下一列。感谢您的帮助