MATLAB实现one-hot 我们以x=[2,2,3]为例 I=eye(max(x)) x_one_hot=I(x,:) 运行后输出 x_one_hot = 0 1 0 0 1 0 0 0 1 就是我们要的one-hot编码