Documentation Center

  • Trial Software
  • Product Updates

coder.resize

Package: coder

Resize a coder.Type object

Syntax

t_out = coder.resize(t, sz, variable_dims)
t_out = coder.resize(t, sz)
t_out = coder.resize(t,[],variable_dims)
t_out = coder.resize(t, sz, variable_dims, Name, Value)
t_out = coder.resize(t, 'sizelimits', limits)

Description

t_out = coder.resize(t, sz, variable_dims) returns a modified copy of coder.Type t with upper-bound size sz, and variable dimensions variable_dims. If variable_dims or sz are scalars, they are applied to all dimensions of t. By default, variable_dims does not apply to dimensions where sz is 0 or 1, which are fixed. Use the 'uniform' option to override this special case. coder.resize ignores variable_dims for dimensions with size inf. These dimensions are always variable size. t can be a cell array, in which case, coder.resize resizes all elements of the cell array.

t_out = coder.resize(t, sz) resizes t to have size sz.

t_out = coder.resize(t,[],variable_dims) changes t to have variable dimensions variable_dims while leaving the size unchanged.

t_out = coder.resize(t, sz, variable_dims, Name, Value) resizes t using additional options specified by one or more Name, Value pair arguments.

t_out = coder.resize(t, 'sizelimits', limits) resizes t with dimensions automatically becoming variable based on the limits vector. When the size S of a dimension is greater than or equal to the first threshold defined in limits, the dimension becomes variable size with upper bound S. When the size S of a dimension is greater than or equal to the second threshold defined in limits, the dimension becomes unbounded variable size.

Input Arguments

limits

Two-element vector (or a scalar-expanded one-element vector) of variable-sizing thresholds. If the size sz of a dimension of t is greater than or equal to the first threshold, the dimension becomes variable size with upper bound sz. If the size sz of a dimension of t is greater than or equal to the second threshold, the dimension becomes unbounded variable size.

sz

New size for coder.Type object, t_out

t

coder.Type object that you want to resize

variable_dims

Specify whether each dimension of t_out should be fixed or variable size.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'recursive'

Setting recursive to true resizes t and all types contained within it

Default: false

'uniform'

Setting uniform to true resizes t but does not apply the heuristic for dimensions of size one.

Default: false

Output Arguments

t_out

Resized coder.Type object

Examples

Change a fixed-size array to a bounded variable-size array

t = coder.typeof(ones(3,3))     
% t is     3x3
coder.resize(t, [4 5], 1)       
% returns :4 x :5
% ':' indicates variable-size dimensions
 

Change a fixed-size array to an unbounded variable-size array

t = coder.typeof(ones(3,3))     
% t is 3x3
coder.resize(t, inf)           
% returns :inf x :inf
% ':' indicates variable-size dimensions
% 'inf' indicates unbounded dimensions
 

Resize a structure field

ts = coder.typeof(struct('a', ones(3, 3))) 
% returns field a as 3x3
coder.resize(ts, [5, 5], 'recursive', 1)   
% returns field a as 5x5
 

Make a fixed-sized array variable size based on bounded and unbounded thresholds

t = coder.typeof(ones(100,200))     
% t is 100x200
coder.resize(t,'sizelimits', [99 199])   
% returns :100x:inf
% ':' indicates variable-size dimensions
% :inf is unbounded variable size

See Also

| |

Was this topic helpful?