find and reshape function ion matlab

1 view (last 30 days)
Rica
Rica on 29 Jan 2013
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 Comment
Jan
Jan on 29 Jan 2013
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?

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 29 Jan 2013
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 on 29 Jan 2013
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 Comment
Walter Roberson
Walter Roberson on 29 Jan 2013
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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!