Equation code?

3 次查看(过去 30 天)
zayed
zayed 2011-12-12
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;

采纳的回答

Walter Roberson
Walter Roberson 2011-12-12
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,:)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by