필터 지우기
필터 지우기

select some component of vector

조회 수: 6 (최근 30일)
zina ben
zina ben 2012년 6월 27일
댓글: Juan Andrés Meza Silva 2021년 5월 20일
Hello!
i think i chose the wrong example last time
I have this vector:
V = [12 45 30 4 56 79 8 94 55]';
i need just to used
V1 = [79 8 94 ]
the component numb 6 , 7 and 8
what can i do
please help me. Thanks in advance

답변 (1개)

the cyclist
the cyclist 2012년 6월 27일
If you have inputs V and V1, and you are looking for the output to be [6 7 8], then you want
out = find(ismember(V,V1));
If you have inputs V and [6 7 8], and you are looking for the output to be V1, then you want
out = V([6 7 8])
or
out = V(6:8)
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 6월 27일
An approach without using find() is
[tf, out] = ismember(V, V1);
Juan Andrés Meza Silva
Juan Andrés Meza Silva 2021년 5월 20일
THANK U IN CAPS.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by