Create a pyramidal matrix

Python 2, 109 99 98

n=input()
r=range(1,abs(n)+1)
l=r+r[~n|-2::-1]
for j in l:print[abs((n<0)*~-n+min(i,j))for i in l]

Create list

l = [1,2,3,4,5,4,3,2,1]

and play with it a little.


edit: new way of creating list + thx Lynn for two bytes


EXCEL: 126 bytes

=MAX(MIN(MIN(CELL("row",RC)-1,CELL("col",RC)-1),MIN(((ABS(R1C1)-1)*2+3)-CELL("row",RC),((ABS(R1C1)-1)*2+3)-CELL("col",RC))),0)

Try it online*

Note: this answer uses R1C1 Notation. If you're going to try this yourself. you need to turn that on in Excel options.

the formula given needs to be in every cell present beyond (2,2). Put your desired pyramid size into (1,1).

quick screen-cap of the formula in action:
enter image description here

Here is an Additional picture of some fun with conditional formatting!

*It takes a very long time to update, currently.


MATL, 26 24 bytes

oXyG|to-:"TTYaQ]G0<?G+q|

Try it online! Or verify all test cases (slightly modified code to serve as test suite).

Explanation

The code first builds the output array assuming positive input n. The array is initiallized as 1 for odd input or as the empty array for even input (this is created as an identity matrix with size equal to the parity of the input). Then the following is repeated n times for even input, and n-1 times for odd input: extend the array with a frame containing 0, and add 1 to all elements.

For example, the steps for input n are:

  • Initial array:

    1
    
  • Extend with frame:

    0 0 0
    0 1 0
    0 0 0
    
  • Add 1:

    1 1 1
    1 2 1
    1 1 1
    
  • Extend with frame:

    0 0 0 0 0
    0 1 1 1 0
    0 1 2 1 0
    0 1 1 1 0
    0 0 0 0 0
    
  • Add 1:

    1 1 1 1 1
    1 2 2 2 1
    1 2 3 2 1
    1 2 2 2 1
    1 1 1 1 1
    

This gives the correct output for positive input. If the input is negative, the array needs to be modified by adding the input minus 1 and taking the absolute value:

    3 3 3 3 3
    3 2 2 2 3
    3 2 1 2 3
    3 2 2 2 3
    3 3 3 3 3

You can watch the array growing (modified code to show intermediate steps) at MATL Online! The interpreter is still a beta. If it doesn't work press "Run" again or reload the page.

Commented code

o        % Take input implicitly and push 0 if even or 1 if odd
Xy       % Identity matrix of that size. Gives either 1 or empty array
G|       % Absolute value of input
to-      % Subtract 1 if odd
:"       % For loop: repeat that many times
  TTYa   %   Add a frame of zeros in the two dimensions
  Q      %   Add 1 to all elements
]        % End for
G        % Push input again
0>       % is it negative?
?        % If so
  G      %   Push input again
  +      %   Add
  q      %   Subtract 1
  |      %   Absolute value
         % End if implicitly
         % Display implicitly