extracting value from a vector

조회 수: 8 (최근 30일)
Andrea Miceli
Andrea Miceli 2021년 3월 18일
댓글: Andrea Miceli 2021년 3월 18일
Hello everybody!
i need help extracting some values ​​from a vector. More specifically, I have two vectors A and B (vector A contains 1: 3000 while vector B contains 10 random numbers) and I need to extract from vector A only the values ​​contained in Vector B. I have already tried with "== "and" iseq ", but the vectors are not the same length and therefore I cannot perform the operation.
thank you for your time!

채택된 답변

Olof Engström
Olof Engström 2021년 3월 18일
[intersection, indices] = intersect(A,B)
There you get the intersecting values and the indices to the intersecting values in A
  댓글 수: 1
Andrea Miceli
Andrea Miceli 2021년 3월 18일
Thank you! It's worked.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by