8.2.51 scalarexpand

Function: [out1, out2, …, outN] = scalarexpand (x1, x2, …, xN)

Expand scalar inputs to match size of non-scalar inputs.

Expands each scalar input argument to match the size of the non-scalar input arguments, and returns the expanded values in the corresponding output arguments. repmat is used to do the expansion.

Works on any input types that support size, isscalar, and repmat.

It is an error if any of the non-scalar inputs are not the same size as all of the other non-scalar inputs.

Returns as many output arguments as there were input arguments.

Examples:

x1 = rand(3);
x2 = 42;
x3 = magic(3);
[x1, x2, x3] = scalarexpand (x1, x2, x3)