MATLAB: Unable to correctly identity type of stochastic.

homework

I'm working on code to identify the type of stochastic (ex: double, left, or right). I got the code to run but the output is incorrect.
>> A=[0.5, 0, 0.5; 0, 0, 1; 0.5, 0, 0.5]
A =
0.5000 0 0.5000
0 0 1.0000
0.5000 0 0.5000
>> P=stochastic(A)
Matrix A is a doubly %Not a double
P =
0.5000 0 0.5000
0 0 1.0000
0.5000 0 0.5000
Here is the code.
w=1:rows
k=1:columns
if (sum(A(w,:) == 1)&&(sum(A(:,k)) ==1))
disp('Matrix A is a double')
P=A;
break;
Any advice/help?

Best Answer

tol = 1E-5;
sdown = all(abs(sum(A,1) - 1) < tol);
sside = all(abs(sum(A,2) - 1) < tol);
if sdown && sside
disp('two')
elseif sdown
disp('vertical')
elseif sside
disp('horizontal')
else
disp('Yes we have no stochasticism, we have no stochasticism today!')
end