How to write a Function that returns a matrix
Ältere Kommentare anzeigen
Write a function named checkerBoard that will receive a positive integer n as an input argument. The function will return an n-by-n matrix made up of alternating ones and zeros as shown in the example below. The first element of the matrix returned (first row, first column: ans(1,1) ) should be 1. I'm stuck on how to write the for loop?
4 Kommentare
Jan
am 30 Sep. 2016
There is no "example below". It sounds like you've copied the text of your homework assignment without showing any own effort to solve the problem. Please post, what you have tried so far.
Thorsten
am 30 Sep. 2016
Sarah, this is obviously homework. So what have you tried so far? Any ideas of how to generate the checkerboard?
Sarah Sadeq
am 3 Okt. 2016
Bearbeitet: Walter Roberson
am 3 Okt. 2016
Walter Roberson
am 3 Okt. 2016
mod(n,n); doesn't do anything useful. It calculates a value and then throws the value away.
Antworten (1)
Chi-Hsien Tang
am 30 Sep. 2016
Bearbeitet: Chi-Hsien Tang
am 30 Sep. 2016
0 Stimmen
Maybe try checkerboard(1,2,2)==0?
1 Kommentar
Sarah Sadeq
am 30 Sep. 2016
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!