warning: value not equal to 1 or 0 converted to 1 warning: called from ...Although this is a warning, it is likely to be the cause of your Octave program's bug. Let's see what this error is about and how to fix it.

Although this article is written specifically for Octave, it may apply to Matlab as well. In case you don't know what they are, they are both numerical computing software.

Cause

The cause of this warning is that you are trying to assign a value other than 0 or 1 to a

**bool matrix**. A bool matrix can only take a value of 0 or 1. Let's see the following trace:

debug> Y(Y == 0) = 10; warning: value not equal to 1 or 0 converted to logical 1 warning: called from svmTrain at line 36 column 9 saveSvmModelForRecognizingDigits at line 23 column 11 debug> typeinfo(Y) ans = bool matrixAs you can see, Y is a bool matrix. But we want a

**matrix**, not a

**bool matrix**. A matrix can represent any integer. A bool matrix can only represent a one or a zero.

Solution

Therefore, the solution is to convert the bool matrix to a normal matrix. See the following code.

%note Y is a bool matrix; we gotta convert it to a matrix Y2=0; %the following for loop is for copying every value from Y to Y2 for i=1:size(Y,1), for j=1:size(Y,2), Y2(i,j)=Y(i,j); end endNow Y2 is a

**matrix**. You can use Y2.

I know it's a bit stupid, but it works. If you have a better way to create a

**matrix**feel free to share it with me.

Questions? Let me know!