How to write a Function that returns a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2016년 10월 3일
mod(n,n); doesn't do anything useful. It calculates a value and then throws the value away.
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!