Sunday, June 8, 2008

Assign 6, Q2

To create a 256x256 matrix with 1s in the (i, i+1) position and zeros everywhere else using the tril and/or triu functions in octave.

Here is what tril and triu mean:



Here are one line commands in octave that give you a 9x9 matrix with 1s in the (i,i+1) position and zeros everywhere else using the tril and triu command.



To make a 256x256 matrix with 1s in the (i,i+1) position and zeros everywhere else we simply write:

triu(ones(256),1)-triu(ones(256),2).

No comments: