How to set an upper and lower limit on a data set from a matrix
조회 수: 9 (최근 30일)
이전 댓글 표시
I need to set an upper and lower limit on the numbers in a data set that belongs to a matrix.
How would I go about doing this?
댓글 수: 2
채택된 답변
Walter Roberson
2015년 8월 3일
at_least = -5.1234; %for example
at_most = 308.42; %for example
new_matrix = min(max(YourMatrix, at_least), at_most);
Now new_matrix has had every value less than at_least replaced with at_least, and every value greater than at_most replaced with at_most.
댓글 수: 0
추가 답변 (1개)
James Tursa
2015년 8월 4일
Assuming you want to extract all the rows where the 3rd column meets your conditions:
GalList = your matrix
lower_limit = 176.71;
upper_limit = 198.71;
x = (GalList(:,3) >= lower_limit) & (GalList(:,3) <= upper_limit);
extracted_rows = GalList(x,:);
댓글 수: 3
James Tursa
2015년 8월 4일
Do you mean read in only those lines, or create a new file with only those lines, or what? How are you currently reading this file?
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!