We have moved to @ Placement Papers Hub !! Visit our new website here for more..

Creating an M x N Array of Random Numbers using rand and setting any value that is < 0.2 to ‘0’ and any value that is ≥ 0.2 to ‘1’ by moving through the Array, Element by Element.


Creating an M x N Array of Random Numbers using rand and   setting any value that is < 0.2 to ‘0’ and any value that is ≥ 0.2 to ‘1’ by moving through the Array, Element by Element.


A = rand(4,7)
A =
    0.5308    0.5688    0.1622    0.1656    0.6892    0.2290    0.5383
    0.7792    0.4694    0.7943    0.6020    0.7482    0.9133    0.9961
    0.9340    0.0119    0.3112    0.2630    0.4505    0.1524    0.0782
    0.1299    0.3371    0.5285    0.6541    0.0838    0.8258    0.4427
>> [M,N] = size(A)
M =
     4
N =
     7

>> for j = 1:M
for k = 1:N
if A(j,k) < 0.2
A(j,k) = 0;
else
A(j,k) = 1;
end
end
end
>> M=A
M =

     1     1     0     0     1     1     1
     1     1     1     1     1     1     1
     1     0     1     1     1     0     0
     0     1     1     1     0     1     1