Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Create a vector that gives the information about the locations of each element

1 vue (au cours des 30 derniers jours)
Ismaeel
Ismaeel le 29 Déc 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
I have the vector A: A=[1 3 7], and I want to create another array, say B, that contains the locations of the elements of A. That is, B=[1 0 1 0 0 0 1] Thanks
  1 commentaire
Ismaeel
Ismaeel le 29 Déc 2016
Modifié(e) : James Tursa le 29 Déc 2016
A=[1 3 7];
v=zeros(1,max(A));
% for i=1:length(A)
v(A(:))=1
% end

Réponses (1)

KSSV
KSSV le 29 Déc 2016
Modifié(e) : KSSV le 29 Déc 2016
A=[1 3 7] ;
B = zeros(1,max(A)) ;
B(A) = 1
Or Straight away
B(A) = 1

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by