The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a function called identity that creates a square identity matrix, which is a matrix whose elements are 0 except for ones on the diagonal (from top left to bottom right). The diagonal consists of those elements whose row and column indexes are the same: (1,1), (2,2), etc. The function takes one positive integer input argument, which is the size of the matrix, and returns the matrix itself as an output argument. For example, identity(4) must return a 4-by-4 identity matrix. You are not allowed to use the built-in eye or diag functions. (Hint: you can index into a matrix with a single index and MATLAB will handle it as if it was a vector using column-major order.)
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll