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

3 次查看(过去 30 天)
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 中查找有关 Logical 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by