How to index variables from column B based on column A condtion

1 次查看(过去 30 天)
I have an array of variables with 2 columns.
A containing input and B containing output.
looks something like this
A=[ 200;200;200...;400;400;...;600;600]
B[5.5;6.5;6.0...;8.5;9.6;....;14.3;18.4]
how do i index the values in column B into seperate arrays based on column A values?
im sure it involves logical indexing just not sure the procedure

采纳的回答

Cris LaPierre
Cris LaPierre 2022-3-22
Logical indexing and assignment
A = [1 2];
B = [3 4];
% assign results to new variables
C = B(A==1)
C = 3
D = B(A==2)
D = 4

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by