Need help to specify unique values of a vector
1 次查看(过去 30 天)
显示 更早的评论
I am using the unique command to specify the unique values of a vector that i read from different files. While it works ok for some of them, there are a lot that after i keep just the "unique" values i discover that there are still same values. The code i use is the following
idx=find(unique(Z));
Z=Z(idx);
My problem is that i use the Z variable for interpolation later in my code, so if the values aren't dinstict i get error
Error using ==> interp1 at 261 The values of X should be distinct.
Thank you in advance
0 个评论
采纳的回答
Fangjun Jiang
2011-11-13
You probably didn't use the function right.
find() finds indices of nonzero elements. I don't know why you would run idx=find(unique(Z)).
unique() will return the unique values in Z, but it could also return the index. See the full help of unique().
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!