1. Engineering
2. Computer Science
3. matlab coding help make a function called creatematrix which takes...

# Question: matlab coding help make a function called creatematrix which takes...

###### Question details

Matlab coding help

Make a function called createMatrix which takes 2 parameters, and returns a square matrix,

where:

 The 1st parameter is the number of rows and also the number of columns in the matrix

to be returned

 The 2nd parameter is the value that should be found in the top-right half of the matrix,

including the main diagonal from the top left to the bottom right

 All other elements in the matrix should contain the value which is the negative of the

2nd parameter

For example, if your function was given the values 5 and 3 (in this exact order), then your

function should return the following matrix:

3 3 3 3 3

-3 3 3 3 3

-3 -3 3 3 3

-3 -3 -3 3 3

-3 -3 -3 -3 3

Your function should return an empty matrix if the 1st parameter is non-positive.

You may assume that you will always be given integer parameters.