Matlab - Undefined Error for Input Arguments of Ty

2019-05-11 19:26发布

问题:

This question already has an answer here:

  • “Undefined function 'function_name' for input arguments of type 'double'.” 3 answers

I'm trying to write a function that does what conv2(h1,h2,A) & conv2(...'shape') does without using the built-in function. (speed is currently not an issue). as defined here: http://www.mathworks.co.uk/help/matlab/ref/conv2.html

These are my commands:

    imgC = imread('camerman.tif');
    imgC = double(imgC);

    sigma = 1;
    inp = (-1 .*2.5 .*sigma):1:(2.5 .* sigma);                                  
    gauss1d = (1/(sigma .* sqrt(2*pi))).*exp(-(inp.^2/(2.*sigma.*sigma)));      
    gaussprime = diff(gauss1d);       

    x = conv2fft(gaussprime,1,imgC , 'same');   
    y = conv2fft(1,gaussprime.',imgC , 'same'); 
    blur = conv2fft (gauss1d, gauss1d, imgC );

This is my error:

    Undefined function 'convfft' for input arguments of type 'double'.
    Error in conv2fft (line 81) `if size(convfft(a(1,:),r),1)==1`

If I run the same commands but use the conv2 function:

    imgC = imread('camerman.tif');
    imgC = double(imgC);

    sigma = 1;
    inp = (-1 .*2.5 .*sigma):1:(2.5 .* sigma);                                  
    gauss1d = (1/(sigma .* sqrt(2*pi))).*exp(-(inp.^2/(2.*sigma.*sigma)));      
    gaussprime = diff(gauss1d);       

    x = conv2(gaussprime,1,imgC , 'same');   
    y = conv2(1,gaussprime.',imgC , 'same'); 
    blur = conv2(gauss1d, gauss1d, imgC );

It works fine?... I've been searching around and staring at this code for hours. I just can't see it. Anyone notice what is wrong with my function?

回答1:

Undefined function 'xxx' for input arguments of type 'double' typically indicates that the function xxx is not on the path.

To confirm that this is indeed the issue, type which convfft at the command line, since which should indicate where Matlab knows the file is located.

If the file is not found, make sure that it exists on your computer, and add the file's parent folder to the Matlab path.