MATLAB: Matrix Manipulation code help

image processingMATLABmatrix manipulation

I have a training label for 3 different classes in a matrix of size 1*178 example t=[1 1 1 3 1 2 3 1 … …..]. Anyone please help me to write an efficient code for generating a new matrix of size 3*178 where based on the value in "t", the corresponding location in columns should be 1.
for the above example. the output will be like the following matrix:
[1 1 1 0 1 0 0 1…. 0 0 0 0 0 1 0 0….. 0 0 0 1 0 0 1 0…..]

Best Answer

[t(:) == 1, t(:) == 2, t(:) == 3]