Matlab - Double类型的输入参数的未定义错误

Rea*_*ion 3 double matlab runtime-error undefined

我想写做什么的功能conv2(h1,h2,A)conv2(...'shape')确实不使用内置的功能.(速度目前不是问题).如下定义:http://www.mathworks.co.uk/help/matlab/ref/conv2.html

这些是我的命令:

    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 );
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

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

如果我运行相同的命令但使用该conv2功能:

    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 );
Run Code Online (Sandbox Code Playgroud)

它工作正常吗?...我一直在寻找并盯着这段代码几个小时.我只是看不到它.有人注意到我的功能有什么问题吗?

Jon*_*nas 6

Undefined function 'xxx' for input arguments of type 'double'通常表示该功能xxx不在路径上.

要确认这确实是问题,请which convfft在命令行键入,因为which应指明Matlab知道文件所在的位置.

如果找不到该文件,请确保它在您的计算机上存在,并将该文件的父文件夹添加到Matlab路径.

  • @Reanimation:Matlab知道`conv2fft`,但不知道'convfft`.使用文件系统搜索文件.如果找不到,则应该可以在文件交换中找到它. (2认同)