#Day23- #100DaysChallenge- Matlab Loops| ChessBoard Matrix

#Day23-Chess Board Matrix

Task: Create a matrix with pixel value 0 and 255 as like chess board. Take row and column size from the user.




Matlab Code:
function chessboard(m,n)
for i=1:1:m
    for j=1:1:n
        if mod((i+j),2)==0
            a(i,j)=0;
        else
                a(i,j)=255;
        end
       
    end
end
   
imshow(a);

end

Sample Input and Output:
 chessboard(22,10)

Click here for Video Description




1 comment: