viclia
viclia
2019-04-18 17:07

关于matlab函数定义的问题,定义了但是提示未定义 求大神解答

  • 开发语言

这是.m文件

以下是关于函数的定义
function p = init_phi(im,type)
im = dimensionz(im);
%m = im(150:250,150:250);
[dim1, dim2] = size(im);
p = zeros(dim1+2,dim2+2);

switch lower (type)
    case 'circle'
        for i = 1:dim1+2
            for j = 1:dim2+2
                p(i,j) = (sqrt((i/dim1-0.5)^2 + (j/dim2-0.5)^2) - 0.2) * 30;
            end
        end

    case 'grid'
        for i = 1:dim1+1
            for j = 1:dim2+1
                p(i,j) = sin(i*pi/5) + sin(j*pi/5);
            end
        end

    case 'circle 2'
        for i = 1:dim1+2
            for j = 1:dim2+2
                p(i,j) = (sqrt(((i+2)/dim1-0.3)^2 + (j/dim2-0.9)^2) - 0.2) * 30;
            end
        end

    case 'square'
        %p = zeros(dim1+2,dim2+2);
        p(floor((dim1+2)/3:(dim1+2)*2/3),floor((dim2+2)/3:(dim2+2)*2/3)) = 1;  
%             p(floor(((dim1+2)/3)+1):floor((dim1+2)*2/3)-1,floor((dim2+2)/3)+1:floor((dim2+2)*2/3)-1) = 0;
        p = bwdist(p)-bwdist(1-p)+im2double(p)-.5;
end
end

运行后提示 未定义函数或变量 'init'。求大神详细解答ORZ

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答