find and reshape function ion matlab

조회 수: 3 (최근 30일)
Rica
Rica 2013년 1월 29일
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
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
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()

Rica
Rica 2013년 1월 29일
Hi i forgot something: index=ind
% ind= [find(fr==8.1); find(fr==8.2); find(fr==8.3); find(fr==8.4);...... ; find(fr==10)];
id=reshape(ind,length(ind)/20,[]);20:is the number of fr to be found.
%fr is a big matrix.
what do you mean with duplicate value?
i try to find something like : ind=find[(fr==a)] whre a=8.1:step:10.
thank you!
  댓글 수: 1
Walter Roberson
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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by