matlab - After using `uniquetol` to an array, how can i find back where the entries are in the array? -


>> = [12345678.123456789, 12345678.123456788] =    1.0e+07 *    1.234567812345679   1.234567812345679 >> unique(a) ans =    1.0e+07 *    1.234567812345679   1.234567812345679 >> uniquetol(a,eps) ans =      1.234567812345679e+07 

so 2 numbers considered same within tolerance of eps.

however, after obtaining 1.234567812345679e+07. want know entries in a match 1.234567812345679e+07 within tolerance of eps (which reasonable after use uniquetol eps tolerance before.)

but

find(abs(a-uniquetol(a,eps))<eps) ans =      2 

even

>> find(abs(a-uniquetol(a,eps))<=eps) ans =      2 >> find(abs(a-uniquetol(a,eps))<=eps*10) ans =      2 

does not give me 2 entries.

it

>> find(abs(a-uniquetol(a,eps))<=eps*10000000) ans =      1     2 

or

>> find(abs(a-uniquetol(a,eps))<=eps(uniquetol(a,eps))) ans =      1     2 

will give me first entries. (find(abs(a-uniquetol(a,eps))<=eps(uniquetol(a,eps))) not work numbers.)

why? because use uniquetol(a,eps) before, not uniquetol(a,eps*10000000). why find has set @ higher tolerance uniquetol.

generally a not of 2 entries only, if set tolerance of find high or using find(abs(a-uniquetol(a,eps))<=eps(uniquetol(a,eps))) double count original entries in a. because uniquetol(a,eps) produces 2 entries sometimes.

there 2 additional outputs can request uniquetol. the documentation page it, [c,ia,ic] = uniquetol(___) returns index vectors ia , ic, such c = a(ia) , a~c(ic) (or a(:)~c(ic) if a matrix), ~ means values within tolerance of each other. think you're looking use ic here. example, ic == 1 gives logical mask of entries of a "map" c(1).


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -