How to convert a row vector into desired matrix?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
For example, we have a row vector A
A = [ 4 3 6 2 5];
And I want to convert this row vector into a matrix of '5 X 7' containing zeros and ones only. Required matrix is
% Matrix A
A = [0 0 0 1 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 1 0
0 1 0 0 0 0 0
0 0 0 0 1 0 0]
Every elment of the row vector represents the position of '1' in each row of the matrix.
Guys, please help me in getting the solution to this problem.
0 Commenti
Risposta accettata
Più risposte (1)
Walter Roberson
il 22 Feb 2017
Modificato: Walter Roberson
il 22 Feb 2017
full(ind2vec(A)).'
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!