Matlab: Behavior of the unique function
matlab
Solution
The behaviour has changed with R2013a, if you need the old behaviour use:
`size(unique([],'legacy'))`
If you need code for both versions, I would recommend to write some function which calls `unique(x,'legacy')` for new versions and `unique(x)` for old versions.
btw: same issue with `union`, `intersect`, `setdiff`, `setxor` and `ismember`
Problem
I'm currently migrating code from R2012a to R2013b. I noticed that the `unique` function behavior has changed: R2012a ``` >> size(unique([])) ans = 0 0 ``` R2013b ``` >> size(unique([])) ans = 0 1 ``` It seems counter-intuitive to me that a 0x0 matrix would become a 0x1 matrix after removing doublons, which is essentially what the unique function does. Does anybody has a rationale for this?