Noob problem: Defining a fumction and passing values issues an error "Subscript indices must either be real positive integers or logicals."

3 vues (au cours des 30 derniers jours)
I have the following function:
function [ result ] = SSD( i1, i2 )
if size(i1) == size(i2)
[r, c] = size(i1)
result = -(sum(sum((double(i1) - double(i2)).^2)) / (r*c));
result = 'invalid';
I would like to pass it to images that contain gray values only and the error:
Subscript indices must either be real positive integers or logicals.
Popes up. For debugging purpuse I tried calling the function in this way:
SSD(zeros(3), ones(3));
The error is still there. But if I call the function in this way:
SSD(ones(3), ones(3));
No error. What is happening? Why doesn't the function like zero values?

Réponse acceptée

Jon le 21 Sep 2015
Runs fine on my machine-no errors. 2015a. Do you have a variable named SSD or zeros?
  2 commentaires
Veselin Ivanov
Veselin Ivanov le 21 Sep 2015
Aaaa. Thanks :). I cleaned the workspace and now it worked. I have to get used to that old variables hang around :).

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Image Processing and Computer Vision dans Help Center et File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by