Cody

# Problem 1065. Make a 1 hot vector

Solution 1798481

Submitted on 27 Apr 2019
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   Fail
assert(isequal(one_hot(1,1),1))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test1 (line 1) assert(isequal(one_hot(1,1),1))

2   Fail
assert(isequal(one_hot(2,1),[1 0]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test2 (line 1) assert(isequal(one_hot(2,1),[1 0]))

3   Fail
assert(isequal(one_hot(3,3),[0 0 1]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test3 (line 1) assert(isequal(one_hot(3,3),[0 0 1]))

4   Fail
assert(isequal(one_hot(4,1),[1 0 0 0]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test4 (line 1) assert(isequal(one_hot(4,1),[1 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test5 (line 1) assert(isequal(one_hot(5,2),[0 1 0 0 0]))

6   Fail
assert(isequal(one_hot(6,1),[1 0 0 0 0 0]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test6 (line 1) assert(isequal(one_hot(6,1),[1 0 0 0 0 0]))

7   Fail
assert(isequal(one_hot(7,1),[1 0 0 0 0 0 0]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test7 (line 1) assert(isequal(one_hot(7,1),[1 0 0 0 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test8 (line 1) assert(isequal(one_hot(8,7),[0 0 0 0 0 0 1 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test9 (line 1) assert(isequal(one_hot(9,7),[0 0 0 0 0 0 1 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test10 (line 1) assert(isequal(one_hot(10,4),[0 0 0 1 0 0 0 0 0 0]))

11   Fail
assert(isequal(one_hot(11,11),[0 0 0 0 0 0 0 0 0 0 1]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test11 (line 1) assert(isequal(one_hot(11,11),[0 0 0 0 0 0 0 0 0 0 1]))

12   Fail
assert(isequal(one_hot(12,1),[1 0 0 0 0 0 0 0 0 0 0 0]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test12 (line 1) assert(isequal(one_hot(12,1),[1 0 0 0 0 0 0 0 0 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test13 (line 1) assert(isequal(one_hot(13,6),[0 0 0 0 0 1 0 0 0 0 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test14 (line 1) assert(isequal(one_hot(14,6),[0 0 0 0 0 1 0 0 0 0 0 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test15 (line 1) assert(isequal(one_hot(15,12),[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test16 (line 1) assert(isequal(one_hot(16,13),[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test17 (line 1) assert(isequal(one_hot(17,4),[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]))

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

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test18 (line 1) 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   Fail
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]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test19 (line 1) 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   Fail
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]))

Error: File: one_hot.m Line: 3 Column: 3 "zeros" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. Error in Test20 (line 1) 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]))