필터 지우기
필터 지우기

Exclude data points from 2 arrays, based on a 3rd array

조회 수: 2 (최근 30일)
Nerma Caluk
Nerma Caluk 2022년 6월 24일
답변: Voss 2022년 6월 24일
I have either 3 vectors, or a matrix with 3 columns, example: a, b, c; which are related by each row. I need to exclude values from a and b (or the whole row of the matrix) and then plot them, based on the values that they are related to c. For example:
a = [533 534 535 536 700]';
b = [123 124 125 126 200]';
c = [11100010010 11100010010 11100010010 11100010010 11100010011]';
I want to remove all values from a and b that are NOT CORRESPONDING to value of c = 11100010010 (like the last element of c, which indicates removal of last values from a and b, 200 and 700).
Thank You for your help!

답변 (1개)

Voss
Voss 2022년 6월 24일
a = [533 534 535 536 700]';
b = [123 124 125 126 200]';
c = [11100010010 11100010010 11100010010 11100010010 11100010011]';
idx = c ~= 11100010010;
a(idx) = [];
b(idx) = [];
disp(a); disp(b);
533 534 535 536 123 124 125 126

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by