Ideas
Follow


uniqueN function would be useful

Chris Hooper on 23 Aug 2024 (Edited on 23 Aug 2024)
Latest activity Reply by John D'Errico on 29 Aug 2024

isequaln exists to return true when NaN==NaN.
unique treats NaN==NaN as false (as it should) requiring NaN to be replaced if NaN is not considered unique in a particular application. In my application, I am checking uniqueness of table rows using [table_unique,index_unique]=unique(table,"rows","sorted") and would prefer to keep NaN as NaN or missing in table_unique without the overhead of replacing it with a dummy value then replacing it again. Dummy values also have the risk of matching existing values in the table, requiring first finding a dummy value that is not in the table.
uniquen (similar to isequaln) would be more eloquent.
Please point out if I am missing something!
Steven Lord
Steven Lord on 27 Aug 2024
This seems like a reasonable enhancement request to file with Technical Support, though if it gets implemented the way it would be implemented might not be as a new function but as an option for the existing functions. Would you want all six of the set functions (intersect, ismember, setdiff, setxor, union, and unique) to have new <name>n versions? Or would having some or all of them accept a flag (similar to the order flag and occurrence flag) be acceptable?
John D'Errico
John D'Errico on 29 Aug 2024
Totally agree. There is no reason to proliferate functions, when we could just use the existing functions, with a flag.
Chris Hooper
Chris Hooper on 27 Aug 2024 (Edited on 27 Aug 2024)
I like your suggestion to add this capability as an optional argument (flag) to the six set functions.
It could also make sense to consider flags for other data types such as NaT, missing, and [].
Noted I should take this up with tech support, thanks!
Les Beckham
Les Beckham on 23 Aug 2024 (Edited on 26 Aug 2024)
Why not write your own? Shouldn't be too difficult, and you'll have it to use from now on (while waiting for Mathworks to implement, if they ever do).
Chris Hooper
Chris Hooper on 27 Aug 2024 (Edited on 27 Aug 2024)
I implemented the workaround described above but I suggest this functionality fits core Matlab. I have not researched working with tables in mex.

Tags

No tags entered yet.