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

2 ビュー (過去 30 日間)
Nicholas Kavouris
Nicholas Kavouris 2022 年 3 月 22 日
回答済み: Cris LaPierre 2022 年 3 月 22 日
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]
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 件)





Community Treasure Hunt

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

Start Hunting!

Translated by