# Octave: representing a matrix composed of symbolic types and scalars.

06 May 2022Suppose you want to create a matrix (or vector) that has some scalars and some symbolic types, in Octave. (Short post about Octave’s symbolic computation package: here.)

An example:

```
syms a b c
M0 = [a 0 0; 0 b 0; 0 0 c];
M1 = [a 0 0; 0 b 0; 0 0 1];
```

The expected output would be:

```
M0 = (sym 3×3 matrix)
⎡a 0 0⎤
⎢ ⎥
⎢0 b 0⎥
⎢ ⎥
⎣0 0 c⎦
M1 = (sym 3×3 matrix)
⎡a 0 0⎤
⎢ ⎥
⎢0 b 0⎥
⎢ ⎥
⎣0 0 1⎦
```

but NO – executing M1 will give you

```
error: octave_base_value::map_value(): wrong type argument 'scalar'
```

It turns out this is a known bug, relevant SO post.

the workaround is to enclose the rows that are all scalars with brackets, like

```
M1 = [a 0 0; 0 b 0; [0 0 1]];
```

and then we get the desired output:

```
M1 = (sym 3×3 matrix)
⎡a 0 0⎤
⎢ ⎥
⎢0 b 0⎥
⎢ ⎥
⎣0 0 1⎦
```