Find doesn't seem to work with Matrix larger than 127x127

조회 수: 1 (최근 30일)
Bartosz
Bartosz 2023년 1월 28일
댓글: Walter Roberson 2023년 1월 28일
[i,j]=find(A);
A is matrix of size n where n varies in size from 100 to 2000 (each time calculation is completed it's incremented by 50). For n = 100 all is fine, but once I reach 150 i and j only record values to 127.
If it is relevant A is matrix of adjacency for complete binary tree of n nodes
  댓글 수: 5
Bruno Luong
Bruno Luong 2023년 1월 28일
편집: Bruno Luong 2023년 1월 28일
FIND works just fine. Just your A matrix filling does something that you are not expected.
max(i) = 150, max(j) = 127
Bartosz
Bartosz 2023년 1월 28일
Thanks, problem has been solved. Sorry for your wasted time on such a simple mistake of mine

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

채택된 답변

Walter Roberson
Walter Roberson 2023년 1월 28일
I am certain that find works. I speculate that you are putting the values together in an array with values of datatype int8. When you put together values of mixed data type, the output result is typically the most restricted data type of all of the inputs.
  댓글 수: 3
Bartosz
Bartosz 2023년 1월 28일
Huge thanks! I didn't see this one. If I ever met you, I'd buy you a beer. Once again thanks a lot
Walter Roberson
Walter Roberson 2023년 1월 28일
I would suggest that your code would probably be clearer if you were to build A as being n by 2 by something -- you could reshape it back afterwards.

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

추가 답변 (1개)

Jan
Jan 2023년 1월 28일
This observation does not match the facts:
X = randi([0, 1], 150, 150);
[i,j] = find(X);
max(i)
ans = 150
max(j)
ans = 150
If you observe a very strange behavior, which implies, that hundrets of thousands Matlab users did not notice a serious problem in standard function for many years, you can be sure, that your observation is wrong.
If no indices > 127 are found in your case, there are no non-zeros with such indices. The limit of 127 sounds like the maximum value of int8 values.
Please post some code, which reproduces the problem. I'm sure, that the proble ist not the find() command, but hidden in your code.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by