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

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Make a vector of length *N* that consists of all zeros except at index *k*, where it has the value 1.

Example:

Input

N = 6; k = 2; vector = one_hot(N,k);

Output

vector = [0 1 0 0 0 0]

228 correct solutions
52 incorrect solutions

Last solution submitted on Jul 13, 2015

2 players like this problem

1 Comment