undefined variable even with equal sign, tried to see if it was the () but no luck
조회 수: 1 (최근 30일)
이전 댓글 표시
if(n)>=(2)
any(a(k)== 43)&&any(a(k)==32);
XXXIIPBS = find(a==32);
XLIIIPBS = find(a==43);
PBS = (A(XXXIIPBS).*a(XXXIIPBS))+(A(XLIIIPBS).*(a(XLIIIPBS)));
end
if (n)>=(3)
any(a(k)==10)&&any(a(k)==21)&&any(a(k)==32);
Xeggavosand = find(a==10);
XXIeggavosand = find(a==21);
XXXIIeggavosand = find(a==32);
EVS = A(Xeggavosand).*a(Xeggavosand)+A(XXIeggavosand).*a(XXIeggavosand)+A(XXXIIeggavosand).*a(XXXIIeggavosand);
end
if (n)>= (4)
any(a(k)==10)&&any(a(k)==54)&&any(a(k)==65)&&any(a(k)==76);
any(a(k)==87)&&any(a(k)==98)&&any(a(k)==12)&&any(a(k)==34);
LXXXVIISM = find(a==87);
XIISM = find(a==12);
XCVIIISM = find(a==98);
XXXIVSM = find(a==34);
SBSMO = (A(LXXXVIISM).*a(LXXXVIISM))+((A(XIISM).*a(XIISM)))+(A(XXXIVSM).*a(XXXIVSM))+(A(XCVIIISM).*a(XCVIIISM));
Xom = find(a==10);
LIV = find(a==54);
LXV = find(a==65);
LXXVI= find(a==76);
OM = ((A(Xom).* a(Xom))+(A(LIV).*a(LIV))+(A(LXV).*a(LXV))+(A(LXXVI).*(a(LXXVI))));
end
if PBS >= 107
disp('Peanut Butter Sandwich: 1 Peanut butter jar, 2 slices of bread')
end
if EVS >= 95
disp('EGGAVOCADOSANDWICH: 1 egg, 1 avocado, 2 slices of bread')
end
if OM >= 215
disp('Spinich Cheese Omlet: 2 eggs, 1 cup of spinach, 1/4 tbs of butter, 1 slice of cheese')
end
if SBSMO >= 318
disp ('Strawberry Banna Smoothie: 2 cups of strawberries, 1 banana, 1 cup of milk, 1 cup of ice')
end
disp('Recipes available to make are:')
my input is:
How many ingredients do you have? 2
Type code of Ingrediant #1: 32
Type quantity of Ingrediant #1: 4
Type code of Ingrediant #2: 43
Type quantity of Ingrediant #2: 1
Peanut Butter Sandwich: 1 Peanut butter jar, 2 slices of bread
Undefined function or variable 'EVS'.
Error in SFSU918374852_FinalProject (line 54)
if EVS >= 95
댓글 수: 1
Walter Roberson
2020년 8월 9일
편집: Walter Roberson
2020년 8월 9일
any(a(k)== 43)&&any(a(k)==32);
That evaluates a condition, figuring out whether the condition is true or false. Then, it throws away the result of the expression. You are not testing the result, and you are not displaying the result, and you are not assigning the result to a variable.
Likewise for
any(a(k)==10)&&any(a(k)==54)&&any(a(k)==65)&&any(a(k)==76);
답변 (1개)
Cris LaPierre
2020년 8월 9일
EVS is only defined in the case where n>=3 (btw, you don't need the parentheses around n and 3). What is your value of n? If it's less than 3, this is your problem.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!