in matlab we try to make a table for logic, and we have a function called "functionNot" which turn 0's into 1 and 1's into 0;
function functionNot(x)
for x >=0 && x <= 2
if x == 0
disp(1);
elseif x == 1
disp(0);
else disp (2);
end
end
end
and we want to make a table, for table we have 3 arrays X,Y, AND tnot ( which keeps value of "functionNot") and we have array X and array Y
x=[1; 1 ;1; 0; 0; 0; 2; 2; 2];
y=[1; 0; 2 ;1; 0; 2; 1; 0; 2];
tnot(x) =[ functionNot(x(1)); functionNot(x(2));functionNot(x(3));functionNot(x(4));functionNot(x(5));functionNot(x(6));functionNot(x(7));functionNot(x(8));functionNot(x(9))]
tand(x,y) =[ functionAnd(x(1),y(1));
T= table(x, y, tnot(x));
but it always throwing error "Too many Output Arguments" anyone know how to fix this ?
functionto learn about function declarationsforloop with a logical statement as indices is ... odd to say the least.whileloops andifstatements go with logical values, whereasforloops usually accept an array to iterate over. Also, unlessxis integer, be careful of floating point round off when comparing brutally with==without any form of tolerance.tand(x,y) =[ functionAnd(x(1),y(1));won't work neither as there is a closing bracket missing....