I want to create a matrix where the middle diagonal is symmetrically decreasing to the sides, like this:
5 4 3 2 1
4 5 4 3 2
3 4 5 4 3
2 3 4 5 4
1 2 3 4 5
The matrix has to be 100x100 and the values are between 0
and 1
.
Until now I only get the edges and the middle diagonal, but can't get the idea on how to automatically fill the rest.
v = ones(1,100);
green = diag(v);
green(:,1) = fliplr(0:1/99:1);
green(1,:) = fliplr(0:1/99:1);
green(100,:) = 0:1/99:1;
green(:,100) = 0:1/99:1;