Finding specific values from a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I have the matrix Values (1X3000), upper limit (=100) and lower limit(=30). What I want is for the Specific_Values matrix to contain the values that satisfy the following relationship,
lower_limit<= Values<=upper_limit
Below is the code I wrote but all the values of Values matrix are entered in the Specific_Values matrix.
Values % 1X3000
lower_limit=30;
upper_limit=100;
for i=1:length(Values)
if (Values(i)>=lower_limit && Values<=upper_limit)
Specific_Values(i)=Values(i);
end
end
How to solve this problem? Your help is invaluable.
댓글 수: 0
채택된 답변
Davide Masiello
2022년 10월 4일
See the example below (I used a smaller array for better readibility)
Values = randi(200,1,20)
lower_limit=30;
upper_limit=100;
Specific_Values = Values(Values >= lower_limit & Values <= upper_limit)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Financial Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!