Why am I getting Subscript indices must either be real positive integers or logicals?

1 view (last 30 days)
Here is the part of my code giving me problems:
channelToCorrelate = A; %A is where the modes are in real space
correlationOutput = normxcorr2(mode(:,:A), Image(:,:, channelToCorrelate));
subplot(2, 2, 3);
imshow(correlationOutput, []);
axis on;
it brings this
Subscript indices must either be real positive integers or logicals.
Error in crosscorrelationcode (line 26)
correlationOutput = normxcorr2(mode(:,:,1), Image(:,:, channelToCorrelate));
A is a matrix of numbers including complex numbers. I thought that was the problem so i tried to use
correlationOutput = logical (correlationOuput)
correlationOutput = round(correlationOuput)
I got the same error both times so I then used
channelToCorrelate = logical(A)
but that didn't work because A has comle values and round just brought the same error. What am missing?
Neo on 14 Jul 2015
channelToCorrelate is the matrix where a smaller image is in the actual image and image is the image itself. Would my breakpoint be dbstopline26? Thank you for your suggestions

Sign in to comment.

Accepted Answer

Brendan Hamm
Brendan Hamm on 14 Jul 2015
I can see a few error in the line:
correlationOutput = normxcorr2(mode(:,:A), Image(:,:, channelToCorrelate))
1. The syntax does not make sense, is there supposed to be another comma?
This probably should read:
but you mention that A has imaginary values so you cannot use it to index.
2. If channelToCorrelate is the same as A then you cannot use this to index into Image.
What is it you are attempting to do with this indexing?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by