Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
Ismaeel
Ismaeel 2016년 12월 29일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Ismaeel
Ismaeel 2016년 12월 29일
편집: James Tursa 2016년 12월 29일
A=[1 3 7];
v=zeros(1,max(A));
% for i=1:length(A)
v(A(:))=1
% end

답변 (1개)

KSSV
KSSV 2016년 12월 29일
편집: KSSV 2016년 12월 29일
A=[1 3 7] ;
B = zeros(1,max(A)) ;
B(A) = 1
Or Straight away
B(A) = 1

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by