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:
Post a Comment