Cody

# Problem 1065. Make a 1 hot vector

Solution 276668

Submitted on 9 Jul 2013 by Michael Weidman
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status 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]))
``` ```