Octave/ Matlab is fun – Enter the Matrix

f = rot90((diag((ones(5,1)))) + hankel(zeros(5,1),2*(ones(5,1))),1)
warning: hankel: column wins anti-diagonal conflict
f =

0 2 2 2 3
0 0 2 3 2
0 0 1 2 2
0 1 0 0 2
1 0 0 0 0

hess(diag((ones(4,1))))
ans =

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

eig(diag((ones(4,1))))
ans =

1
1
1
1

diag([1,2,3],4)
ans =

0 0 0 0 1 0 0
0 0 0 0 0 2 0
0 0 0 0 0 0 3
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

rot90(shift(rot90(rand(4),1),1),3)
ans =

0.141505 0.100645 0.200515 0.552900
0.163904 0.081520 0.505508 0.356016
0.458187 0.275491 0.472148 0.434868
0.988882 0.267269 0.680475 0.424024

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: