Matlab에서, 이런 경우가 생긴다.
"첫 번째 column이 2인 모든 rows를 얻고 싶다."
"시간을 나타내는 column에서, 5시인 경우의 데이터만 얻고 싶다."
한 column에서 특정 값을 가지는, 모든 rows를 얻고 싶을 때가 생긴다.
다음과 같이 논리 인덱스(logical index)를 이용한다.
A = [1 0.1 0.3 0.5;2 0.2 0.5 0.7;1 0.3 0.5 0.8;2 0.1 0.2 0.3];
B = A(:, 1) == 2;
C = A(B, :)
더 간단하게는 다음과 같다.
C = A(A(:, 1) == 2,:);
https://mathworks.com/matlabcentral/answers/2381-accessing-matrix-rows-using-logical-indexing
Accessing Matrix Rows using Logical Indexing - MATLAB Answers - MATLAB Central
This is probably a very simple question to answer, and I'm sure its been asked a million times, but I just can't seem to find an answer that works for me. Let's say I have an array like this: A = [1 1 1 1;2 2 2 2;3 3 3 3;4 4 4 4]; A = 1 1 1 1 2 2 2 2 3 3 3
kr.mathworks.com
'IT' 카테고리의 다른 글
C++에서 음악 파일 동시 재생하기 (0) | 2019.06.09 |
---|---|
OpenCV putText 한글 넣기 (Visual Studio) (1) | 2019.06.01 |
OpenCV (c++) 3 설치, Visual studio에서 실행 (0) | 2019.05.28 |
LPSTR과 CString 문자열 길이 구하기 (0) | 2019.05.22 |
Visual Studio 2015, Sublime text3 자동 들여쓰기 (0) | 2019.05.17 |