Main Content

coder.resize

Resize coder.Type object

Description

example

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

example

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, the function applies the scalars 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. The coder.resize function ignores variable_dims for dimensions with size inf. These dimensions are variable size. t can be a cell array of types, in which case, coder.resize resizes all elements of the cell array.

example

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

example

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

example

t_out = coder.resize(t,'sizelimits',limits) resizes t with dimensions 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 an unbounded variable size.

Examples

collapse all

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

t = coder.typeof(ones(3,3))     
t = 

coder.PrimitiveType
   3×3 double
coder.resize(t,inf)           
ans = 

coder.PrimitiveType
   :inf×:inf double
% ':' indicates variable-size dimensions

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

t = coder.typeof(ones(3,3))
t = 

coder.PrimitiveType
   3×3 double
coder.resize(t,[4 5],1)
ans = 

coder.PrimitiveType
   :4×:5 double
% ':' indicates variable-size dimensions

Resize a structure field.

ts = coder.typeof(struct('a',ones(3, 3))) 
ts = 

coder.StructType
   1×1 struct
      a: 3×3 double
coder.resize(ts,[5, 5],'recursive',1)   
ans = 

coder.StructType
   5×5 struct
      a: 5×5 double

Resize a cell array.

tc = coder.typeof({1 2 3}) 
tc = 

coder.CellType
   1×3 homogeneous cell 
      base: 1×1 double
coder.resize(tc,[5, 5],'recursive',1)   
ans = 

coder.CellType
   5×5 homogeneous cell 
      base: 1×1 double

Change a fixed-sized array to a variable size based on bounded and unbounded thresholds.

t = coder.typeof(ones(100,200))
t = 

coder.PrimitiveType
   100×200 double
coder.resize(t,'sizelimits',[99 199])   
ans = 

coder.PrimitiveType
   :100×:inf double
% ':' indicates variable-size dimensions

Input Arguments

collapse all

A row vector of variable-size thresholds. If the value of limits is scalar, the threshold gets scalar-expanded. 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 an unbounded variable size.

Example: coder.resize(t,'sizelimits',[99 199]);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

New size for coder.Type object, t_out

Example: coder.resize(t,[3,4]);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

If t is a coder.CellType object, the coder.CellType object must be homogeneous.

Example: coder.resize(t,inf);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | struct | table | cell | function_handle | categorical | datetime | duration | calendarDuration | fi
Complex Number Support: Yes

Specify whether each dimension of t_out is fixed size or variable size.

Example: coder.resize(t,[4 5],1);

Data Types: logical

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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: coder.resize(t,[5, 5],'recursive', 1);

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

Data Types: logical

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

Data Types: logical

Output Arguments

collapse all

Resized coder.Type object

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | struct | table | cell | function_handle | categorical | datetime | duration | calendarDuration | fi
Complex Number Support: Yes

Limitations

  • For sparse matrices, coder.resize drops the upper bounds for variable-size dimensions.

Introduced in R2011a