gpt4 book ai didi

matlab - 你如何解决 "undefined function or variable ' mamfis'”?

转载 作者:行者123 更新时间:2023-11-30 09:03:21 27 4
gpt4 key购买 nike

我正在 MATLAB r2016a 上进行边缘检测,但出现一个我不明白的错误。我在某个地方看到这个问题发生在r2015a中,这就是我升级到r2016a的原因,但我遇到了同样的问题:

undefined function or variable 'mamfis'

此外,我也收到此错误:

Error: File: edge.m Line: 48 Column: 6
The input character is not valid in MATLAB statements or expressions.

Irgb = imread('IMG_1769.png');
Igray = rgb2gray(Irgb);

figure
image(Igray,'CDataMapping','scaled')
colormap('gray')
title('Input Image in Grayscale')
I = im2double(Igray);
Gx = [-1 1];
Gy = Gx';
Ix = conv2(I,Gx,'same');
Iy = conv2(I,Gy,'same');
figure
image(Ix,'CDataMapping','scaled')
colormap('gray')
title('Ix')
figure
image(Iy,'CDataMapping','scaled')
colormap('gray')
title('Iy')
% edgeFIS=mamfis;
edgeFIS = mamfis('Name','edgeDetection');
edgeFIS = addInput(edgeFIS,[-1 1],'Name','Ix');
edgeFIS = addInput(edgeFIS,[-1 1],'Name','Iy');
sx = 0.1;
sy = 0.1;
edgeFIS = addMF(edgeFIS,'Ix','gaussmf',[sx 0],'Name','zero');
edgeFIS = addMF(edgeFIS,'Iy','gaussmf',[sy 0],'Name','zero');
edgeFIS = addOutput(edgeFIS,[0 1],'Name','Iout');
wa = 0.1;
wb = 1;
wc = 1;
ba = 0;
bb = 0;
bc = 0.7;
edgeFIS = addMF(edgeFIS,'Iout','trimf',[wa wb wc],'Name','white');
edgeFIS = addMF(edgeFIS,'Iout','trimf',[ba bb bc],'Name','black');
figure
subplot(2,2,1)
plotmf(edgeFIS,'input',1)
title('Ix')
subplot(2,2,2)
plotmf(edgeFIS,'input',2)
title('Iy')
subplot(2,2,[3 4])
plotmf(edgeFIS,'output',1)
title('Iout')
r1 = "If Ix is zero and Iy is zero then Iout is white";
r2 = "If Ix is not zero or Iy is not zero then Iout is black";
edgeFIS = addRule(edgeFIS,[r1 r2]);
edgeFIS.Rules

Ieval = zeros(size(I));
for ii = 1:size(I,1)
Ieval(ii,:) = evalfis(edgeFIS,[(Ix(ii,:));(Iy(ii,:))]');
end

figure
image(I,'CDataMapping','scaled')
colormap('gray')
title('Original Grayscale Image')

figure
image(Ieval,'CDataMapping','scaled')
colormap('gray')
title('Edge Detection Using Fuzzy Logic')

最佳答案

第一个问题,mamfis函数来自模糊逻辑工具箱,因此您需要安装该工具箱才能使用它。它在核心 MATLAB 中不存在。

第二个问题,定义 strings直到 MATLAB R2017a 版本才添加使用双引号 (")。您需要使用单引号 (') 定义字符数组。

关于matlab - 你如何解决 "undefined function or variable ' mamfis'”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59070695/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com