Undefined function or variable 'Store5'. Error in Untitled5 (line 108) Store = [Store1;St​ore2;Store​3;Store4;S​tore5;Stor​e6];

조회 수: 1 (최근 30일)
clear all;
close all;
[A,B,C,D,E,F]=nbc(6);
Y=(~A*~B*C)+(A*~B*D)+(~A*B*E)+(A*B*F);
btab(Y,A,B,C,D,E,F);
Function = [ ];
X1 = [ ];
X2 = [ ];
X3 = [ ];
X4 = [ ];
X5 = [ ];
X6 = [ ];
for i=1:16
if (b2d(Y(i))==0)
Function(i)=0;
else
Function(i)=1;
end
end
for i=1:16
if (b2d(A(i))==0)
X1 (i)=0;
else
X1 (i)=1;
end
end
for i=1:16
if (b2d(B(i))==0)
X2 (i)=0;
else
X2 (i)=1;
end
end
for i=1:16
if (b2d(C(i))==0)
X3 (i)=0;
else
X3 (i)=1;
end
end
for i=1:16
if (b2d(D(i))==0)
X4 (i)=0;
else
X4 (i)=1;
end
end
for i=1:16
if (b2d(E(i))==0)
X5 (i)=0;
else
X5 (i)=1;
end
end
for i=1:16
if (b2d(F(i))==0)
X6 (i)=0;
else
X6 (i)=1;
end
end
for i=1:15
for j = (i+1):16
if ((X1(i) ~= X1(j)) && (X2(i) == X2(j)) && (X3(i) == X3(j)) && (X4(i) == X4(j)) && (X5(i) == X5(j)) && (X6(i) == X6(j)) && (Function(i) ~=Function(j)))
Temp1 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i)];
Temp2 = [X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
Store1 = [Temp1; Temp2];
end
if ((X1(i) == X1(j)) && (X2(i) ~= X2(j)) && (X3(i) == X3(j)) && (X4(i) == X4(j)) && (X5(i) == X5(j)) && (X6(i) == X6(j)) && (Function(i) ~=Function(j)))
Temp1 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i)];
Temp2 = [X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
Store2 = [X1(i) X2(i) X3(i) X4(i) X5(i) Function(i);X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
end
if ((X1(i) == X1(j)) && (X2(i) == X2(j)) && (X3(i) ~= X3(j)) && (X4(i) == X4 (j)) && (X5(i) == X5(j)) && (X6(i) == X6(j)) && (Function(i) ~=Function(j)))
Temp1 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i)];
Temp2 = [X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
Store3 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i);X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
end
if ((X1(i) == X1(j)) && (X2(i) == X2(j)) && (X3(i) == X3(j)) && (X4(i) ~= X4 (j)) && (X5(i) == X5(j)) && (X6(i) == X6(j)) && (Function(i) ~=Function(j)))
Temp1 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i)];
Temp2 = [X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
Store4 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i);X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
end
if ((X1(i) == X1(j)) && (X2(i) == X2(j)) && (X3(i) == X3(j)) && (X4(i) == X4 (j)) && (X5(i) ~= X5(j)) && (X6(i) == X6(j)) && (Function(i) ~=Function(j)))
Temp1 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i)];
Temp2 = [X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
Store5 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i);X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
end
if ((X1(i) == X1(j)) && (X2(i) == X2(j)) && (X3(i) == X3(j)) && (X4(i) == X4 (j)) && (X5(i) == X5(j)) && (X6(i) ~= X6(j)) && (Function(i) ~=Function(j)))
Temp1 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i)];
Temp2 = [X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
Store6 = [X1(i) X2(i) X3(i) X4(i) X5(i) X6(i);X1(j) X2(j) X3(j) X4(j) X5(j) X6(j)];
end
end
end
Store = [Store1;Store2;Store3;Store4;Store5;Store6];
-----------------------------------------------------------------------------------------------
Undefined function or variable 'Store5'.
Error in Untitled5 (line 108)
Store = [Store1;Store2;Store3;Store4;Store5;Store6];
For the store line, it only work up to Store4....I don't know how to fix the error. This code is working under the boolean algebra toolbox V2.2 environment.

답변 (2개)

surabhi
surabhi 2014년 3월 25일
Use the debugger, and see where and why it gives an error at Store5. May be its not getting the inputs for calculating Store5.

Walter Roberson
Walter Roberson 2014년 3월 25일
Each of your Store* variables is not initialized, and is only set conditionally. If that condition is not satisfied then the Store* variable will never have been given a value.
You should be asking yourself why you create the Temp1 and Temp2 variables for all the cases but only use them for the Store1 case.
You should be asking yourself why you have "clear all" in a program. It does not do whatever-it-is that you are thinking that it does. If you are trying to ensure that the values of variables are not present in memory then use a function instead of a script.
You should be asking yourself why you do not have comments in the code.
  댓글 수: 3
Walter Roberson
Walter Roberson 2014년 3월 25일
Your loops run to 16, which is 2^4, suitable for taking each possible combination of 4 binary values. But now you are dealing with 6 binary values so running your loops to 16 is not appropriate.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by