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

Learn moreOpportunities for recent engineering grads.

Apply TodayMake 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]

197 correct solutions
48 incorrect solutions

Last solution submitted on Dec 13, 2014

2 players like this problem

1 Comment