Question: Matlab has built - in commands to create a matrix of all ones ( the command is called ones ( ) ) or all zeros

Matlab has built-in commands to create a matrix of all ones (the command is called ones()) or all zeros (with the
zeros() command). Look up the syntax of these commands and then use them along with array addressing to
create an nn matrix whose entries are all 2's around the perimeter of the matrix and otherwise 1 in locations
where the row and column are even, -1 in locations where row and column are odd, and 0 elsewhere. You may
assume that n is odd. Here is an example of what your matrix would look like for n=9 :
Your code should only be a few lines long, not use any loops, and begin with a line that assigns an odd value to n,
such as:
 Matlab has built-in commands to create a matrix of all ones

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!