Equation code?

3 visualizzazioni (ultimi 30 giorni)
zayed
zayed il 12 Dic 2011
Hi,
I wrote the following code for this equation :
M=(1/K)*sum(zkd*zkd')
,and it's running with out errors ,but all the elements in matrix M (1000*1000) are of the same value (1.1180e+001),and Mz is just one single value (1.7619e+001)despite it should be (1000*1000).Can anybody help,please?
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, []);
M=zeros(K,K); % M ZEROS covariance matrix L*L
for i=1:size(zkd,1); % LOOP covariance matrix calculation
Mz=zkd(i,:)*zkd(i,:)'; %
M=M+Mz;
end
M=M/K;

Risposta accettata

Walter Roberson
Walter Roberson il 12 Dic 2011
zkd(i,:) is going to be 1 by L.
zkd(i,:)' is going to be L by 1.
Doing a matrix multiplication of a (1 by L) and (L by 1) is going to result in a 1 by 1.
Perhaps you want
zkd(i,:)' * zkd(i,:)

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by