How can I multiply 2D matrix with it hermitian?

Hi,
How can I do this in matlab?I want to multiply a matrix with it's hermitian,as the following equation:
M=(1/K)*sum(zkd*zkd'),
zkd is (1000*5).zkd is from a signal(size 5000) and i divide it to blocks with block size equal to 1000,and number of blocks 5.
clear all;
clc
load lab2_data;
x = radar_noise; % input signal
K = 1000; % K CAPITAL is Block Size
L = length(x) - mod(length(x),K); % only full blocks
zkd = reshape(x(1:L), K, []);
Md=zeros(L,L); % M ZEROS covariance matrix L*L
for i=1:size(zkd,1); % LOOP covariance matrix calculation
Mz=zkd(i,:)*zkd(i,:)';
Md=Md+Mz;
end
Md=Md/K;

2 commentaires

Jan
Jan le 15 Déc 2011
And what is wrong with the posted command?
zayed
zayed le 15 Déc 2011
The problem is when I check the results, M is(1000*1000)with all elements in have the same value.

Connectez-vous pour commenter.

 Réponse acceptée

>> zkd = rand(30,3) + i*rand(30,3);
>> R = sum(zkd * zkd');
>> size(R)
ans =
1 30
>> R
R =
Columns 1 through 2
43.7252707339352 - 14.3845494385565i 37.9012903137849 - 1.21833325457709i
Columns 3 through 4
44.0278780546839 - 5.91428978829146i 40.0850287858898 - 10.9783386248396i
The exact values are not important, but it is clear that all of the values are not the same.
If your zkd is 1000 by 5 then zkd*zkd' is going to be 1000 by 1000, and sum(zkd*zkd') is going to be 1 by 1000, in contradiction to your indication that M is 1000 by 1000.

5 commentaires

zayed
zayed le 15 Déc 2011
I have edited the posted thread.Md (5000*5000) with all elements have the same value,L=5000.Mz is a single value only despite it's a matrix
Walter Roberson
Walter Roberson le 15 Déc 2011
We've already gone through this.
zkd(i,:) is going to be 1 by 5. Multiply that by the 5 by 1 zkd(i,:)' and you are going to get a 1 x 1 result. And you add that one by one result to the 5 by 5 array M, which is adding a scalar and a matrix, which is defined as adding the *same* value to each matrix entry. You do that for the 5 different columns, each time getting out a scalar result that is going to be added to the entire matrix. Of course the matrix is going to come out with values that are all equal: that's how you constructed it.
Do you want to get out a 1000 x 1000 result, or a 5 by 5 result?
1000 by 1000:
zkd(:,i) * zkd(:,i)'
5 by 5:
zkd(i,:)' * zkd(i,:)
Please! Do elementary array-size checking for your multiplications.
zayed
zayed le 15 Déc 2011
how can I set Md to be 5 by 5,Md=zeros(,)?
Walter Roberson
Walter Roberson le 15 Déc 2011
Md=zeros(L,L);
zayed
zayed le 15 Déc 2011
But L=5000.and this give the following error :
??? Error using ==> unknown
Matrix dimensions must agree.
Error in ==> cov3 at 11
Md=Md+Mz;

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by