필터 지우기
필터 지우기

If I have an array with values and then another array with each value's category, how would I remove values with certain categories?

조회 수: 1 (최근 30일)
%For example if
Data = (1.2, 3.4, 6.7)
Category = (1, 4, 1)
%How would I remove 1.2 and 6.7 since they each have a category of 1?

채택된 답변

drummer
drummer 2020년 10월 21일
편집: drummer 2020년 10월 21일
First, your notation for array is misguided.
notation for arrays is [ ].
If you want only remove, reducing the size of your Data array, try this:
Data = [1.2, 3.4, 6.7];
Cat = [1, 4, 1];
Data(Cat == 1) = [];
Your output will be:
Data =
3.4
Accept the answer if that helps.
Cheers

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by