# resize() Function & Examples

Use the resize() matrix function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## resize

#### resize(x, size)

#### resize(x, size, defaultValue)

Try it yourself:

```calculio
resize([1,2,3,4,5], [3])
resize([1,2,3], [5])
resize([1,2,3], [5], -1)
resize(2, [2, 3])
resize("hello", [8], "!")
```

[size](https://calcul.io/function/size/index.md)

[subset](https://calcul.io/function/subset/index.md)

[squeeze](https://calcul.io/function/squeeze/index.md)

[reshape](https://calcul.io/function/reshape/index.md)

---

## resize(): Changing Collection Size

**resize()** changes a collection or matrix to requested dimensions. Unlike [reshape()](https://calcul.io/function/reshape/index.md), it may add new positions or discard existing data when the total size changes.

## Data-loss caution

Reducing a dimension can remove entries, so inspect the original with [size()](https://calcul.io/function/size/index.md) and keep a copy with [clone()](https://calcul.io/function/clone/index.md) when needed. Enlarging an array requires a defined fill behavior; make default values explicit.

Use [zeros()](https://calcul.io/function/zeros/index.md) or [ones()](https://calcul.io/function/ones/index.md) when creating a new fixed-size matrix is clearer. resize is best for controlled shape adaptation, not as a substitute for validating input dimensions.

[All functions](https://calcul.io/functions/index.md)
