How can I write a function called checkerboard

How can I write a function called checkerboard that takes as input two positive integer scalars, n and m, in that order. The function must create and return board, which is an n-­‐by-­‐m matrix. Every element of board is either 0 or 1. The first element, board(1,1) is 1. No direct neighbors in the matrix, vertically or horizontally, can be equal. That is, a 1 element cannot have 1 immediately preceding or following it in the same row or column.

댓글 수: 5

Jan
Jan 2015년 10월 30일
This sounds like a homework question. So please show us, what you have tried so far and ask a specific question.
Surfnerd
Surfnerd 2015년 10월 30일
편집: Image Analyst 2015년 10월 30일
Hello,
This is what I have,
function board = checkerboard(n , m)
board = zeros(n,m);
board (1:2:n , 1:2:m)=1;
board (2:2:n , 2:2:m)=1;
end
Congratulations - you did it yourself. Do you have any questions?
Adam
Adam 2015년 10월 30일
So what is the problem?
Surfnerd
Surfnerd 2015년 10월 31일
I figured it out on my own but I was really stuck initially. I was looking for help with a starting point. In the I reread the question multiple times then a light went off and my function seemed to work.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Raspberry Pi Hardware에 대해 자세히 알아보기

질문:

2015년 10월 30일

댓글:

2015년 10월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by