# size() Function & Examples

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

## size

#### size(x)

Try it yourself:

```calculio
size(2.3)
size("hello world")
a = [1, 2; 3, 4; 5, 6]
size(a)
size(1:6)
```

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

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

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

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

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

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

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

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

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

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

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

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

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

---

## size(): Inspecting Array Dimensions

**size()** returns the dimensions of an array or matrix. It is essential for validating data before matrix operations, slicing, or reshaping.

## Prevent shape errors

Check size before [multiply()](https://calcul.io/function/multiply/index.md), [reshape()](https://calcul.io/function/reshape/index.md), or [concat()](https://calcul.io/function/concat/index.md). Matching total counts is not always enough: matrix multiplication requires compatible inner dimensions.

Use [row()](https://calcul.io/function/row/index.md) and [column()](https://calcul.io/function/column/index.md) after confirming an index is present. For an empty collection, dimensions can still be meaningful, so handle zero-length axes explicitly.

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