필터 지우기
필터 지우기

Find function and storing in cell

조회 수: 1 (최근 30일)
Morten Jørgensen
Morten Jørgensen 2019년 3월 21일
편집: Walter Roberson 2019년 3월 25일
Hi
I'm trying to write a program that stores the values 0 < X < 1
I have an array X wich are 15000x14 and I want to store the row numbers in a cell every time the values are between 0 and 1
in some cases there are multiple values that 0 < X < 1
How should I write this?
[x,y] =find(0 < X < 1);
when I do this it still gives me numbers that are negative
Thanks Morten

채택된 답변

Walter Roberson
Walter Roberson 2019년 3월 21일
In MATLAB, except for some symbolic contexts, the expression 0 < X < 1 is parsed as ((0 < X) < 1) . The 0 < X part is done first and gives a result that is either 0 (false) or 1 (true). Then that 0 or 1 is compared < 1 and that is going to give 0 where the result of the first comparison was true (because 1 < 1 is false) and 1 where the result of the first comparison was true (because 0 < 1 is true.)
You need to use 0 < X & X < 1
  댓글 수: 2
Morten Jørgensen
Morten Jørgensen 2019년 3월 21일
Thanks.
And how can I index the row numbers in a cell?
Walter Roberson
Walter Roberson 2019년 3월 25일
편집: Walter Roberson 2019년 3월 25일
mask = any(0 < X & X < 1, 2);
rows_with_match = find(mask);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by