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 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!