Error using min Matrix dimensions must agree.

Greetings ... I will be new in matlab and in this community, I am going to you because I have a small problem with a project, which tries to make a fuzzy controller ... I got a code from a controller that made a few Changes insignificant, but it is not working, and shows me an error in the use of the min () function. Someone who can help me with this problem please
%
paso = 0.01;
valCong=0:paso:1;
PC=trapmf(valCong,[0 0 0.1 0.35]);
MC=trimf(valCong,[0.2 0.5 0.8]);
AC=trapmf(valCong,[0.65 0.9 1 1]);
paso2=0.1;
tiempo=0:paso2:55;
PTV=trapmf(tiempo,[0 0 7.5 15]);
MTV=trimf(tiempo,[10 27.5 45]);
LTV=trapmf(tiempo,[40 47.5 55 55]);
nivCong=0.5;
n=find(valCong==nivCong);
B1 = min(PTV,PC(n));
B2 = min(MTV,MC(n));
B3 = min(LTV,AC(n));
B = max(B1,max(B2,B3));
TV = defuzz(tiempo,B,'centroid');
tiempoVerde=round(TV,0);
Este codigo me da el siguiente error
"Error using min
Matrix dimensions must agree.
Error in Oquendo_Calama (line 53)
B1 = min(PTV,PC(n));"

답변 (2개)

John D'Errico
John D'Errico 2017년 1월 11일
편집: John D'Errico 2017년 1월 11일

0 개 추천

Apparently, PTV is a matrix. Right? What size is that matrix?
Apparently, PC(n) is a matrix. Right? What size is that matrix?
They are not the same size. Read the error message. What sense would it make to try to take the min between a 3x3 and a 2x2 matrix? None. While I don't know the actual sizes of your matrices, the above statement still applies.

댓글 수: 1

Stephen23
Stephen23 2017년 1월 11일
Cesar Herbas's "Answer" moved here:
What happens is that I try to do is to program my own fuzzy controller, and that's why I'm not using Fuzzy Logic Toolbox, so far as PTV and PC are not actually arrays but rather they are fuzzy sets, and I explained that "B1 = Min (PTV, PC (n)) "makes a cut of the PTV set at the height of the fusing value 'n' and that value stores it in B1

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2017년 1월 11일

0 개 추천

Your find() operation is returning the empty matrix for n.
You have find(valCong==nivCong) which attempts to check for bit-for-bit equality between the floating point number nivCong in the vector 0:paso:1 where paso is not an integer (paso = 0.01). Due to accumulated floating point roundoff, there might not be any entry that exactly equals 0.5.
You should consider using
[tf, n] = ismembertol(nivCong, valCong);
and you should check to be sure that tf returns true (if it is false, no entries matched to within tolerance.)

카테고리

도움말 센터File Exchange에서 Fuzzy Logic in Simulink에 대해 자세히 알아보기

태그

질문:

2017년 1월 11일

답변:

2017년 1월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by