One-hot encoding - MATLAB Cody - MATLAB Central

Problem 46621. One-hot encoding

Difficulty:Rate
Given an array x, say x = [3,1,0,2] – perform one hot encoding. The output looks like this:
Y= [ 0 0 1 0;
0 1 0 0;
0 0 0 1;
1 0 0 0]

Solution Stats

57.14% Correct | 42.86% Incorrect
Last Solution submitted on Jun 15, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers35

Suggested Problems

More from this Author174

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!