MATLAB - 如何绘制Type-2模糊隶属函数?

时间:2017-06-16 08:22:23

标签: matlab plot fuzzy-logic

我需要绘制Interval Type-2模糊隶属函数。

请帮助如何获得这种情节:

this kind of plot

1 个答案:

答案 0 :(得分:0)

我没有统计工具箱,因此我生成了高斯pdf。如果这样做,您可以在一行中编写代码的第一部分。

x = [-3:.1:3];
% Create the x Gaussian distribution
sigma1 = 1;
mu1=0;
normpdf1 = 1/(sigma1*sqrt(2*pi)) * exp(-(x-mu1).^2/(2*sigma1^2));
% Create the y Gaussian distribution
sigma2 = 2;
mu2=0;
normpdf2 = 1/(sigma2*sqrt(2*pi)) * exp(-(x-mu2).^2/(2*sigma2^2));

height = 2; % height in Z direction is the same for all points

for i=1:length(normpdf1)

    len = normpdf2(i)/2;
    xdata = [x(i) x(i) x(i) x(i)];
    ydata = [normpdf1(i)- len normpdf1(i)- len normpdf1(i)+ len 
    normpdf1(i)+ len];
    zdata = [0 height  height 0];

    patch('Xdata',xdata, 'Ydata',ydata, 'Zdata',zdata, 'FaceColor', 'red')
    hold on
end