cross correlation matrix dimension

clc;
close all;
clear all;
X=[1 1 1;1 1 1]
H=[1 2; 3 4; 5 6]
[M N]=size(X);
[P Q]=size(H);
k=1;
l=2;
for m=1:1:M;
for n=1:1:N;,
C=sum(sum(X(m,n).*conj(H(m+k,n+l))))
end
end

1 Kommentar

Image Analyst
Image Analyst am 15 Aug. 2014
Other than "How can I format my code in the Answers forum?" which I did for you and you can do for yourself after you read this, do you have another question?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Roger Stafford
Roger Stafford am 15 Aug. 2014

1 Stimme

The nested for-loops are not doing what you appear to have in mind. You are doing a summation on scalars there. Also some of the column indices for the H array you have defined will fall out of its range and you will get an error message.
Ignoring the problem of out-of-range indices, you appear to want this:
k = 1;
l = 2; % <--Lowercase L
C = sum(sum(X.*H(k+1:k+M,l+1:l+N))); % <--Lowercase L
As Image Analyst indicates, you should always state what your question is.

Gefragt:

am 15 Aug. 2014

Beantwortet:

am 15 Aug. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by