0
votes

I am trying to write a function that inputs takes an array i keep getting this error

??? Undefined function or method 'correlation' for input arguments of type 'uint8'.

here is my function code

enter code here
function[] = correlation (images)
array=zeros(10);
for i= 1:10
    for j= 1:10
        if(i ~= j)
            array (i,j)=corr2(images(:,:,i),images(:,:,j));
        end;
    end
end
maxarray=zeros(1,10)
for i= 1:10
    value=1;
    max=array(i,1);
    for j= 2:10
        if(array(i,j) > max)
            max=array(i,j);
            value=j;
        end
    end
    maxarray(i)=value;
end


minarray=zeros(1,10)

for i= 1:10
    min=1;
    for j= 1:10
        if((i~=j) && (array(i,j) < min))
            min=array(i,j);
            value2=j;
        end;
    end
   minarray(i)=value2;
end

maxarray
minarray

enter code here

can any one please help me :) thank you

1

1 Answers

3
votes

You should define the function as

function correlation(images)

It should be either in a separate file named correlation.m or in a file with another function ( it's nested function in this case).

In addition the file should be stored either in a current working directory or in a directory included in MATLAB path.

Read more about MATLAB functions.