Taking out entries of a Vector to make a new Vector

조회 수: 3 (최근 30일)
Tom
Tom 2019년 8월 11일
댓글: Stephen23 2019년 8월 11일
I have a 400 x 1 column vector, is it possible to 'splice' out every 4-th entry of that vector to end up with a 100 x 1 column vector, plus a 300 x 1 column vector left over from the original vector? Let me know if this doesn't make sense and I can explain further.

채택된 답변

Stephen23
Stephen23 2019년 8월 11일
편집: Stephen23 2019년 8월 11일
Where V is your vector:
X = V(4:4:end);
Y = V;
Y(4:4:end) = [];
  댓글 수: 2
Tom
Tom 2019년 8월 11일
This seems to remove the first and the fifth entry and so on, I need to remove the fourth, the eighth, and so on.
Stephen23
Stephen23 2019년 8월 11일
"This seems to remove the first and the fifth entry and so on, I need to remove the fourth, the eighth, and so on."
Yes it did, because you did not specify the starting element. However changing the code is pretty trivial: I changed my answer from starting at element 1 to starting at element 4.

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by