필터 지우기
필터 지우기

Select rows of different vector that matches a specific condition

조회 수: 6 (최근 30일)
Hello, I have different matrices with different values that were estimated separately from a root matrix (acceleration signal). All the matrices has the similar length for example I will assume that I have three matrices (it may be more).
A=[0.25; 0.30; 0.20; 1.5; 1.3; ..... n]
B=[1; 1.30; 2.0; 3.5; 4.0; ..... n]
C=[-3; 0.25; 0.85; 1.2; -0.70; ..... n]
A new matrix is generated based on the condition that each row meets. For example the condition for each matrices may be the following:
A=A>1.2;
B=B>2.0;
C=C<-0.6
the result will be the following matrix
C=[5, 1.3, 4.0, -0.70] or C=[5], where 5 is the number of row that meets the condition. This will help me to identify the value of the acceleration signal (root matrix where A, B and C were derived) that is not accurate.
Thank you for your help.

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 7월 17일
A=[0.25; 0.30; 0.20; 1.5; 1.3];
B=[1; 1.30; 2.0; 3.5; 4.0];
C=[-3; 0.25; 0.85; 1.2; -0.70];
row = (1:length(C))';
ind = A>1.2 & B>2.0 & C<-0.6;
newC = [row(ind) A(ind) B(ind) C(ind)]
newC = 1×4
5.0000 1.3000 4.0000 -0.7000

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by