フィルターのクリア

How to get the vector rankings as per values without common rankings

2 ビュー (過去 30 日間)
Vishal Sharma
Vishal Sharma 2017 年 1 月 21 日
編集済み: Stephen23 2017 年 1 月 21 日
I have a problem of x=[1 3 4 2 3] ... I want its answer should be a=[1 3 5 2 4]and not in form of a=[1 3 4 2 3]...
These are not giving desired results [~,a]=sort(x) [a,b]=unique(x)

採用された回答

Stephen23
Stephen23 2017 年 1 月 21 日
編集済み: Stephen23 2017 年 1 月 21 日
One easy way is to add a very small value to each element of the vector to make them all unique:
>> x = [1,3,4,2,3];
>> [~,~,c] = unique(x+eps*(1:numel(x)))
c =
1 3 5 2 4
This will work assuming that you have fewer than 1/eps() elements, and that they are all integer.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by