Q1. BUILDING CHECKERBOARD MATRIX:
Write a MATLAB code that generates an m-by-n matrix M, buildup of alternating ones and zeros like in a checkerboard. Your code may go as :
-
First take order of Matrix M from user input.
-
Take a character from user input.
-
If entered character is 'r' then M (1, 1) should be 1, else if it is 'l' then M (1, 1) should be 0.
- And final matrix M should have alternating ones and zeros of order given by user.
(HINT: No two adjacent elements in a row or in a column are same!)
Example for Testing You code:
Input and output should look like this.
SOLUTION:
First Way To solve this Question:
Second Way To solve this Question:
Third Way To solve this Question:
Authored by : Shahid Ali Murtza