How i can create one specific matrix 100X100?

 Accepted Answer

This works:
v = -[1:100]';
vu = triu(repmat(v, 1, size(v,1)));
vl = tril(repmat(-v', size(v,1), 1));
out = vu + vl + diag(-v);

2 Comments

Ty very much, it worked like a charm!!

Sign in to comment.

More Answers (1)

how to create a 240*320 matrix containing the data 0.1991 in all the cells.can anyone help me.

Tags

Asked:

on 12 Jan 2015

Answered:

on 16 May 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!