# Clear or Delete matrix or array

**URL:** <https://community.freefem.org/t/clear-or-delete-matrix-or-array/3149>\
**Category:** General Discussion\
**Created:** [April 25, 2024, 9:19am UTC](https://community.freefem.org/t/clear-or-delete-matrix-or-array/3149 "2024-04-25T09:19:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguelpicos](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@miguelpicos](https://community.freefem.org/u/miguelpicos)\
**Post date:** [April 25, 2024, 9:19am UTC](https://community.freefem.org/t/clear-or-delete-matrix-or-array/3149/1 "2024-04-25T09:19:29Z")

</div>

Hello everyone,

I’m working on some models where I’ve utilized arrays of numbers and matrices. At certain points in the code, I’d like to clear or delete some of them as they are no longer needed, or I’d like to rebuild them from scratch. Is there any functionality that allows for this?

Currently, I’m using the resize function to address this issue, with statements like:

```auto
matrix A; A.resize(100,100);

A(2,2) = 1.;A(5,5) = 1.;A(35,49) = 2.;

A.resize(0,0); A.resize(100,100);

```

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [April 25, 2024, 1:28pm UTC](https://community.freefem.org/t/clear-or-delete-matrix-or-array/3149/2 "2024-04-25T13:28:42Z")

</div>

I think, you can clear the matrix  
like in

```auto
matrix A; A.resize(100,100);

A(2,2) = 1.;A(5,5) = 1.;A(35,49) = 2.;
cout << " A = " << A << endl; 
A.clear; 
cout << " A = " << A << endl; 

```
