Noob problem: Defining a fumction and passing values issues an error "Subscript indices must either be real positive integers or logicals."
조회 수: 2 (최근 30일)
이전 댓글 표시
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));
else
result = 'invalid';
end
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?
댓글 수: 0
채택된 답변
Jon
2015년 9월 21일
Runs fine on my machine-no errors. 2015a. Do you have a variable named SSD or zeros?
댓글 수: 2
Kirby Fears
2015년 9월 21일
Try clearing your workspace before calling SSD.
clear;
SSD(zeros(3), ones(3));
If this works, you probably had a variable named zeros in your workspace.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!