cross correlation matrix dimension
2 views (last 30 days)
Show older comments
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 Comment
Image Analyst
on 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?
Answers (1)
Roger Stafford
on 15 Aug 2014
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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!