A nd B are defined, but i can't get past this line: Csum = fuzarith(x,A,B,'sum'); WHy?

11 visualizaciones (últimos 30 días)
%% 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');
Unrecognized function or variable 'muA_x'.
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 comentarios
Michael
Michael el 8 de Oct. de 2022
thanks, that got me past fuzarith -- don't know what was different
WHat is MuA is that z union function? MATLAB does not like Mu*
Walter Roberson
Walter Roberson el 8 de Oct. de 2022
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.

Iniciar sesión para comentar.

Respuestas (1)

Sam Chak
Sam Chak el 9 de Oct. de 2022
Editada: Sam Chak el 9 de Oct. de 2022
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)'});

Categorías

Más información sobre Fuzzy Inference System Modeling en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by