A nd B are defined, but i can't get past this line: Csum = fuzarith(x,A,B,'sum'); WHy?
조회 수: 7 (최근 30일)
이전 댓글 표시
%% close all, clear all, clc, format compact
N = 10;
minX = .1;
maxX = 1.0;
x = linspace(minX,maxX,N);
A = gaussmf(x,[.7 .9]);
B = gaussmf(x,[.7 .8]);
C = gaussmf(x,[.4 .6]);
D = gaussmf(x,[.5 .7]);
E = gaussmf(x,[.9 1]);
F = gaussmf(x,[.3 .5]);
G = gaussmf(x,[.2 .4]);
H = gaussmf(x,[.8 1]);
Csum = fuzarith(x,A,B,'sum');
Csum2 = fuzarith(x,D,C,'sum');
Csum3 = fuzarith(x,E,F,'sum');
Csum4 = fuzarith(x,C,H,'sum');
Csum5 = fuzarith(x,G,H,'sum');
Csub = fuzarith(x,H,G,'sub');
Cprod = fuzarith(x,A,B,'prod');
Cdiv = fuzarith(x,Csum3,B, 'div');
Csub2 = fuzarith(x,Csum5,F,'sub');
% Plot the functions
ha1=figure;
plot(x,muA_x,'b--',x,muB_x,'m:',x,muC_x,'c');
legend('\mu_{A}(x)=e^{-1/2(x-3)^2}', ...
'\mu_{B}(x)=e^{-1/2(x-4)^2}', ...
'\mu_{C}(x)=e^{-1/2(x-6)^2}');
%saveas(ha1,'ProjectTaskIVQ1.png');
% Union is a MAX operation and Intersection is a MIN operation
% Part a
muAnBnC_x = min(min(muA_x,muB_x),muC_x);
ha=figure;
plot(x,muAnBnC_x,'b--');
title({'Q1 Part a';'\mu_{A\capB\capC}(x)'});
%saveas(ha,'ProjectTaskIVQ1a.png');
% Part b
muAuBuC_x = max(max(muA_x,muB_x),muC_x);
hb = figure;
plot(x,muAuBuC_x,'b--');
title({'Q1 Part b';'\mu_{A\cupB\cupC}(x)'});
%saveas(hb,'ProjectTaskIVQ1b.png');
% Part c
mu_AuB_nC_x = min(max(muA_x,muB_x),muC_x);
mu_Au_BnC_x = max(muA_x,min(muB_x,muC_x));
hc=figure;
plot(x,mu_AuB_nC_x,'b--',x,mu_Au_BnC_x,'m:');
title({'Q1 Part c';'\mu_{(A\cupB)\capC}(x) and \mu_{A\cup(B\capC)}(x)'});
legend('\mu_{(A\cupB)\capC}(x)','\mu_{A\cup(B\capC)}(x)');
%saveas(hc,'ProjectTaskIVQ1c.png');
% Part d
mu_AnB_uC_x = max(min(muA_x,muB_x),muC_x);
mu_An_BuC_x = min(muA_x,max(muB_x,muC_x));
hd=figure;
plot(x,mu_AnB_uC_x,'b--',x,mu_An_BuC_x,'m:');
title({'Q1 Part d';'\mu_{(A\capB)\cupC}(x) and \mu_{A\cap(B\cupC)}(x)'});
legend('\mu_{(A\capB)\cupC}(x)','\mu_{A\cap(B\cupC)}(x)');
%saveas(hd,'ProjectTaskIVQ1d.png');
% Part e
mu_AnB_uC_x = max(min(muA_x,muB_x),muC_x);
mu_An_BuC_x = min(muA_x,max(muB_x,muC_x));
he=figure;
plot(x,1-muAuBuC_x,'b--');
title({'Q1 Part e';'1-\mu_{A\cupB\cupC}(x)'});
%saveas(he,'ProjectTaskIVQ1e.png');
댓글 수: 3
Walter Roberson
2022년 10월 8일
Your mu* appear to be calculated variables, not functions -- since they have to be the same length as x and the size of x is determined at run time. However, nothing in your code is assigning to muA_x muB_x muC_x and we have no idea what values they represent so we cannot suggest what a formula would be for them.
답변 (1개)
Sam Chak
2022년 10월 9일
편집: Sam Chak
2022년 10월 9일
Hi @Michael
Check if this is what you want. The Gaussian functions on your original legend were incorrect. The fuzarith() function is used to perform fuzzy arithmetic.
N = 601;
minX = -2;
maxX = 4;
x = linspace(minX, maxX, N);
A = gaussmf(x,[.7 .9]);
B = gaussmf(x,[.7 .8]);
C = gaussmf(x,[.4 .6]);
% D = gaussmf(x,[.5 .7]);
% E = gaussmf(x,[.9 1]);
% F = gaussmf(x,[.3 .5]);
% G = gaussmf(x,[.2 .4]);
% H = gaussmf(x,[.8 1]);
% Csum1 = fuzarith(x,A,B,'sum');
% Csum2 = fuzarith(x,D,C,'sum');
% Csum3 = fuzarith(x,E,F,'sum');
% Csum4 = fuzarith(x,C,H,'sum');
% Csum5 = fuzarith(x,G,H,'sum');
% Csub1 = fuzarith(x,H,G,'sub');
% Cprod = fuzarith(x,A,B,'prod');
% Cdiv = fuzarith(x,Csum3,B, 'div');
% Csub2 = fuzarith(x,Csum5,F,'sub');
% Plot the functions
ha1 = figure;
plot(x, A, '--', x, B, '-.', x, C), grid on, ylim([-0.2 1.2])
xlabel('x'), ylabel('\bf{\mu}')
title({'The Gaussian functions'})
legend({'$\mu_{A}(x)$', '$\mu_{B}(x)$', '$\mu_{C}(x)$'}, ...
'interpreter', 'latex', 'fontsize', 14);
% Part a
muAnBnC_x = min(min(A, B), C);
ha = figure;
plot(x, muAnBnC_x, 'b-'), grid on, ylim([-0.2 1.2])
xlabel('x'), ylabel('\bf{\mu}')
title({'Q1 Part a'; '\mu_{A \cap B \cap C}(x)'});
% Part b
muAuBuC_x = max(max(A, B), C);
hb = figure;
plot(x, muAuBuC_x, 'b-'), grid on, ylim([-0.2 1.2])
xlabel('x'), ylabel('\bf{\mu}')
title({'Q1 Part b'; '\mu_{A \cup B \cup C}(x)'});
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Fuzzy Inference System Modeling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


