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