MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Solution 168676

Submitted on 27 Nov 2012 by @bmtran

Correct

13Size
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%%
assert(isequal(one_hot(1,1),1))
```

2
Pass

```%%
assert(isequal(one_hot(2,1),[1 0]))
```

3
Pass

```%%
assert(isequal(one_hot(3,3),[0 0 1]))
```

4
Pass

```%%
assert(isequal(one_hot(4,1),[1 0 0 0]))
```

5
Pass

```%%
assert(isequal(one_hot(5,2),[0 1 0 0 0]))
```

6
Pass

```%%
assert(isequal(one_hot(6,1),[1 0 0 0 0 0]))
```

7
Pass

```%%
assert(isequal(one_hot(7,1),[1 0 0 0 0 0 0]))
```

8
Pass

```%%
assert(isequal(one_hot(8,7),[0 0 0 0 0 0 1 0]))
```

9
Pass

```%%
assert(isequal(one_hot(9,7),[0 0 0 0 0 0 1 0 0]))
```

10
Pass

```%%
assert(isequal(one_hot(10,4),[0 0 0 1 0 0 0 0 0 0]))
```

11
Pass

```%%
assert(isequal(one_hot(11,11),[0 0 0 0 0 0 0 0 0 0 1]))
```

12
Pass

```%%
assert(isequal(one_hot(12,1),[1 0 0 0 0 0 0 0 0 0 0 0]))
```

13
Pass

```%%
assert(isequal(one_hot(13,6),[0 0 0 0 0 1 0 0 0 0 0 0 0]))
```

14
Pass

```%%
assert(isequal(one_hot(14,6),[0 0 0 0 0 1 0 0 0 0 0 0 0 0]))
```

15
Pass

```%%
assert(isequal(one_hot(15,12),[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]))
```

16
Pass

```%%
assert(isequal(one_hot(16,13),[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]))
```

17
Pass

```%%
assert(isequal(one_hot(17,4),[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]))
```

18
Pass

```%%
assert(isequal(one_hot(18,9),[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]))
```

19
Pass

```%%
assert(isequal(one_hot(19,9),[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]))
```

20
Pass

```%%
assert(isequal(one_hot(20,13),[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]))
```