On Apr 20, 7:45�pm, John <sampson...@gmail.com> 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 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
>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��20��, ����5ʱ31��,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�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 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�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 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��20��, ����5ʱ31��, 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�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 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.