find and reshape function ion matlab
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi together!
i used this functions to find the index of some element und reshape it in a special manner.
% ind= [find(fr==8.1); find(fr==8.2); find(fr==8.3); find(fr==8.4);...... ; find(fr==10)];
id=reshape(ind,length(index)/20,[]);20:is the number of fr to be found.
%fr is a big matrix.
could someone help to write this in compact way?
thank you
댓글 수: 1
Jan
2013년 1월 29일
Does the order of elements in index matter, or would ismember() do the identification sufficiently already? Are you sure, that length(index) is a multiple of 20 in every case?
답변 (2개)
Walter Roberson
2013년 1월 29일
Your find() are mostly going to return no results.
Is there a connection between "ind" and "index" ?
Is there reason to expect that there will be no duplicate values?
Would histc() be suitable? You can get the indices of the elements from the second output of histc()
댓글 수: 0
Rica
2013년 1월 29일
댓글 수: 1
Walter Roberson
2013년 1월 29일
Could there be more than one entry with value 8.1 ? Is it certain that the number of matches for any given "a" value will be the same?
The reshape can be simpified to
id = reshape(ind, [], 20);
You need to solve the problem that in your search range, only 8.5 and 9.0 and 9.5 and 10 are exactly representable in binary, and 8.1, 8.2, 8.3 and so on are not exactly representable. If the 8.1 value (for example) had been calculated even just slightly different then it would not match the 8.1 value that you search for. Please read http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!