Reply by April 22, 20092009-04-22
On Apr 20, 7:45&#4294967295;pm, John <sampson...@gmail.com> wrote:
> On Apr 20, 4:35&#4294967295;am, Thinking <zhihang.w...@gmail.com> wrote: > > > > > > > I want to use matlab to compute the autocorrelaton matrix of a random > > vector. Here is the code I have written. Is it correct? > > clc; > > vec_num = 1000; > > x = zeros(8,vec_num); > > for i=1:vec_num > > &#4294967295; &#4294967295; x(:,i) = round(randn(8,1)*10); > > end > > > total_matrix = zeros(8,8); > > for i=1:vec_num > > &#4294967295; &#4294967295; for j=1:vec_num > > &#4294967295; &#4294967295; &#4294967295; &#4294967295; total_matrix = total_matrix + x(:,i)*x(:,j)'; > > &#4294967295; &#4294967295; end > > end > > total_matrix = total_matrix / (vec_num*vec_num); > > > %% > > total_matrix is the autocorrelation matrix. > > SP toolbox has a built-in function called corrmtx that will do this > for you. > > John- Hide quoted text - > > - Show quoted text -
Unfortunately, corrmtx doesn't return the _traditional_ correlation matrix. Moctar is correct, you need the XCORR and TIEPLITZ is needed. Something like tempvar = xcorr(vector_1,vector_2); [size_1 size_2] = size(tempvar); size_1 = (size_1 + 1)/2 - 1; R = (toeplitz(tempvar(size_1+1 : 2*size_1+1)))./size_1; should do it. Maurice Givens
Reply by mmoctar April 21, 20092009-04-21
>On Apr 20, 6:46 am, Thinking <zhihang.w...@gmail.com> wrote: >> On 4=D4=C220=C8=D5, =CF=C2=CE=E75=CA=B131=B7=D6,Greg
Heath<he...@alumni.b=
>rown.edu> wrote: >> >> >> >> >> >> > On Apr 20, 4:35 am, Thinking <zhihang.w...@gmail.com> wrote: >> >> > > I want to use matlab to compute the autocorrelaton matrix of a
random
>> > > vector. Here is the code I have written. Is it correct? >> > > clc; >> > > vec_num =3D 1000; >> > > x =3D zeros(8,vec_num); >> > > for i=3D1:vec_num >> > > x(:,i) =3D round(randn(8,1)*10); >> > > end >> >> > > total_matrix =3D zeros(8,8); >> > > for i=3D1:vec_num >> > > for j=3D1:vec_num >> > > total_matrix =3D total_matrix + x(:,i)*x(:,j)'; >> > > end >> > > end >> > > total_matrix =3D total_matrix / (vec_num*vec_num); >> >> > > %% >> > > total_matrix is theautocorrelationmatrix. >> >> > lookforautocorrelation >> >> > Hope this helps. >> >> > Greg >> >> I have googledautocorrelation. But I can't find the answer. So I >> post a message here. Would you like to help me > >Not Google. > >doc lookfor >help lookfor > >Greg > >
you can use xcorr then toeplitz, but take care to the length when compute xcorr. Moctar
Reply by Greg Heath April 20, 20092009-04-20
On Apr 20, 6:46 am, Thinking <zhihang.w...@gmail.com> wrote:
> On 4&#4294967295;&#4294967295;20&#4294967295;&#4294967295;, &#4294967295;&#4294967295;&#4294967295;&#4294967295;5&#689;31&#4294967295;&#4294967295;,Greg Heath<he...@alumni.brown.edu> wrote: > > > > > > > On Apr 20, 4:35 am, Thinking <zhihang.w...@gmail.com> wrote: > > > > I want to use matlab to compute the autocorrelaton matrix of a random > > > vector. Here is the code I have written. Is it correct? > > > clc; > > > vec_num = 1000; > > > x = zeros(8,vec_num); > > > for i=1:vec_num > > > x(:,i) = round(randn(8,1)*10); > > > end > > > > total_matrix = zeros(8,8); > > > for i=1:vec_num > > > for j=1:vec_num > > > total_matrix = total_matrix + x(:,i)*x(:,j)'; > > > end > > > end > > > total_matrix = total_matrix / (vec_num*vec_num); > > > > %% > > > total_matrix is theautocorrelationmatrix. > > > lookforautocorrelation > > > Hope this helps. > > > Greg > > I have googledautocorrelation. But I can't find the answer. So I > post a message here. Would you like to help me
Not Google. doc lookfor help lookfor Greg
Reply by John April 20, 20092009-04-20
On Apr 20, 4:35&#4294967295;am, Thinking <zhihang.w...@gmail.com> wrote:
> I want to use matlab to compute the autocorrelaton matrix of a random > vector. Here is the code I have written. Is it correct? > clc; > vec_num = 1000; > x = zeros(8,vec_num); > for i=1:vec_num > &#4294967295; &#4294967295; x(:,i) = round(randn(8,1)*10); > end > > total_matrix = zeros(8,8); > for i=1:vec_num > &#4294967295; &#4294967295; for j=1:vec_num > &#4294967295; &#4294967295; &#4294967295; &#4294967295; total_matrix = total_matrix + x(:,i)*x(:,j)'; > &#4294967295; &#4294967295; end > end > total_matrix = total_matrix / (vec_num*vec_num); > > %% > total_matrix is the autocorrelation matrix.
SP toolbox has a built-in function called corrmtx that will do this for you. John
Reply by rickman April 20, 20092009-04-20
On Apr 20, 4:35&#4294967295;am, Thinking <zhihang.w...@gmail.com> wrote:
> I want to use matlab to compute the autocorrelaton matrix of a random > vector. Here is the code I have written. Is it correct? > clc; > vec_num = 1000; > x = zeros(8,vec_num); > for i=1:vec_num > &#4294967295; &#4294967295; x(:,i) = round(randn(8,1)*10); > end > > total_matrix = zeros(8,8); > for i=1:vec_num > &#4294967295; &#4294967295; for j=1:vec_num > &#4294967295; &#4294967295; &#4294967295; &#4294967295; total_matrix = total_matrix + x(:,i)*x(:,j)'; > &#4294967295; &#4294967295; end > end > total_matrix = total_matrix / (vec_num*vec_num); > > %% > total_matrix is the autocorrelation matrix.
Nothing to add, just wanted to change the subject back...
Reply by Vladimir Vassilevsky April 20, 20092009-04-20
STUPIDENT


Thinking wrote:

> I want to use matlab to compute the autocorrelaton matrix of a random > vector. Here is the code I have written. Is it correct? > clc; > vec_num = 1000; > x = zeros(8,vec_num); > for i=1:vec_num > x(:,i) = round(randn(8,1)*10); > end > > total_matrix = zeros(8,8); > for i=1:vec_num > for j=1:vec_num > total_matrix = total_matrix + x(:,i)*x(:,j)'; > end > end > total_matrix = total_matrix / (vec_num*vec_num); > > %% > total_matrix is the autocorrelation matrix.
Reply by Thinking April 20, 20092009-04-20
On 4&#4294967295;&#4294967295;20&#4294967295;&#4294967295;, &#4294967295;&#4294967295;&#4294967295;&#4294967295;5&#689;31&#4294967295;&#4294967295;, Greg Heath <he...@alumni.brown.edu> wrote:
> On Apr 20, 4:35 am, Thinking <zhihang.w...@gmail.com> wrote: > > > > > I want to use matlab to compute the autocorrelaton matrix of a random > > vector. Here is the code I have written. Is it correct? > > clc; > > vec_num = 1000; > > x = zeros(8,vec_num); > > for i=1:vec_num > > x(:,i) = round(randn(8,1)*10); > > end > > > total_matrix = zeros(8,8); > > for i=1:vec_num > > for j=1:vec_num > > total_matrix = total_matrix + x(:,i)*x(:,j)'; > > end > > end > > total_matrix = total_matrix / (vec_num*vec_num); > > > %% > > total_matrix is theautocorrelationmatrix. > > lookforautocorrelation > > Hope this helps. > > Greg
I have googled autocorrelation . But I can't find the answer. So I post a message here. Would you like to help me?
Reply by Greg Heath April 20, 20092009-04-20
On Apr 20, 4:35&#4294967295;am, Thinking <zhihang.w...@gmail.com> wrote:
> I want to use matlab to compute the autocorrelaton matrix of a random > vector. Here is the code I have written. Is it correct? > clc; > vec_num = 1000; > x = zeros(8,vec_num); > for i=1:vec_num > &#4294967295; &#4294967295; x(:,i) = round(randn(8,1)*10); > end > > total_matrix = zeros(8,8); > for i=1:vec_num > &#4294967295; &#4294967295; for j=1:vec_num > &#4294967295; &#4294967295; &#4294967295; &#4294967295; total_matrix = total_matrix + x(:,i)*x(:,j)'; > &#4294967295; &#4294967295; end > end > total_matrix = total_matrix / (vec_num*vec_num); > > %% > total_matrix is the autocorrelation matrix.
lookfor autocorrelation Hope this helps. Greg
Reply by Thinking April 20, 20092009-04-20
I want to use matlab to compute the autocorrelaton matrix of a random
vector. Here is the code I have written. Is it correct?
clc;
vec_num = 1000;
x = zeros(8,vec_num);
for i=1:vec_num
    x(:,i) = round(randn(8,1)*10);
end

total_matrix = zeros(8,8);
for i=1:vec_num
    for j=1:vec_num
        total_matrix = total_matrix + x(:,i)*x(:,j)';
    end
end
total_matrix = total_matrix / (vec_num*vec_num);

%%
total_matrix is the autocorrelation matrix.