How can I re-save variable with only certain index values?

조회 수: 3 (최근 30일)
Mary Hemler
Mary Hemler 2020년 6월 5일
편집: Cam Salzberger 2020년 6월 5일
I have a variable, mutualInfoTotal, and I would like to re-save as another variable HD_mutualInfoTotal that only contains the values of mutualInfoTotal that correspond to the following index numbers in mutualInfoTotal: [1:4, 6, 8:10, 12, 15:18, 20:22]. How can I do this?

채택된 답변

Cam Salzberger
Cam Salzberger 2020년 6월 5일
편집: Cam Salzberger 2020년 6월 5일
HD_mutualInfoTotal = mutualInfoTotal([1:4, 6, 8:10, 12, 15:18, 20:22]);
There are a lot of ways to do indexing in MATLAB, and this is one of the most common. If you came up with those index values by using find, consider using logical indexing instead.
-Cam

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by