# matlab negation

In Matlab, you can negate a logical expression or a numeric array using the `~`

operator. Here are a few examples:

- Negating a logical expression:

```
a = true;
b = ~a; % b will be false
```

- Negating a numeric array:

```
x = [1, 2, 3];
y = ~x; % y will be [0, 0, 0]
```

Please note that the `~`

operator performs element-wise negation on numeric arrays. If you want to perform matrix negation, you can use the `-`

operator. For example:

```
A = [1, 2; 3, 4];
B = -A; % B will be [-1, -2; -3, -4]
```

I hope this helps! Let me know if you have any further questions.