how to delete an element from a particular position from a vector of repetitive elements

I want to delete the element from a particular position in the vector as I have repetitive elements in that vector.
For example, I have
A =[1 2 3 2 5];
and I want to delete 2 from 4th position. Help me out

 採用された回答

Cedric
Cedric 2013 年 3 月 23 日
You might just want to use UNIQUE..
>> b = unique(A) ;

2 件のコメント

b = unique(A,'stable');
Cedric
Cedric 2013 年 3 月 23 日
Yes, I assumed 'sorted' as the outcome of removing the 4th element is a sorted vector, but I should have made this assumption explicit and mentioned 'stable.

サインインしてコメントする。

その他の回答 (1 件)

naman
naman 2013 年 3 月 24 日

0 投票

Thanks for the answer, its working for this particular vector. But here the condition is bit different. I mentioned from a particular position because I can have the vector of type
A=[ 1 2 3 2 5 2]
now again, i want to remove only 4th element. So pl consider according to generalize vector. Thanks

1 件のコメント

Cedric
Cedric 2013 年 3 月 24 日
編集済み: Cedric 2013 年 3 月 24 日
A(4) = []
if you want to remove only element #4.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

質問済み:

2013 年 3 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by