Clear Filters
Clear Filters

vector of random natural numbers to matrix

2 views (last 30 days)
Hello, I have a problem with the task, if someone could direct me / tell me how to do it
I have to do:
Create a 100-element vector of random positive numbers and then write it as a matrix with the number of rows equal to the number of unique numbers in the vector and 100 columns
and then to each element of the original vector encode its value as 1 in the field with index equal to the value of this element (one-hot encoding).
Thanks in advance!!!
Jan on 12 Mar 2021
What have you tried so far? What is your Matlab related question?
Adam Danz
Adam Danz on 12 Mar 2021
doc rand
doc randi
doc ismember
doc isequal

Sign in to comment.

Accepted Answer

David Hill
David Hill on 12 Mar 2021
for k=1:length(b)

More Answers (0)


Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!