Function File: [y1, …] = tablify (x1, …)

Create a table out of the input arguments, if possible. The table is created by extending row and column vectors to like dimensions. If the dimensions of input vectors are not commensurate an error will occur. Dimensions are commensurate if they have the same number of rows and columns, a single row and the same number of columns, or the same number of rows and a single column. In other words, vectors will only be extended along singleton dimensions.

For example:

[a, b] = tablify ([1 2; 3 4], 5) 
⇒ a = 
  1 2
  3 4
⇒ b = 
  5 5
  5 5 
[a, b, c] = tablify (1, [1 2 3 4], [5;6;7]) 
⇒ a =
  1 1 1 1
  1 1 1 1
  1 1 1 1
⇒ b =
  1 2 3 4
  1 2 3 4
  1 2 3 4
⇒ c = 
  5 5 5 5
  6 6 6 6
  7 7 7 7

The following example attempts to expand vectors that do not have commensurate dimensions and will produce an error.

tablify([1 2],[3 4 5]) 

Note that use of array operations and broadcasting is more efficient for many situations.

Package: general