is it possible to detect the repeated values using modulo operator (mod 16) of a matrix and replace the repeated mod value with the range from 0-15? Please explain.

2 ビュー (過去 30 日間)
Suppose we have a matrix A=[7871,5995,3451,5583;7151,5093,3251,5485;3227,5835,7647,5295;3475,5253,7375,5773] and its modulo: Mod(A,16)= [15,11,11,15;,15,5,3,13;11,11,15,15;3,5,15,13] The number 15,11,5,3,13 is repeated. I want help, if we take mod 16, the resultant matrix check the 2nd element with 1st and simultaneously 3rd element with previous two and vice versa, if repeated value appear then replace the others than repeated value between the range of 0-15. The resultant matrix contain all unique element of range 0-15. How can we do it? Thanks

回答 (1 件)

Santhana Raj
Santhana Raj 2017 年 3 月 23 日
Hi,
You can use the command unique. Go through the documentation.
Another way is to use find. After getting the mod array, check for each element to be repeating and replace it with [].you can use a single line command using find.
Hope it helps.
Raj
  1 件のコメント
FAHEEM MUSHTAQ
FAHEEM MUSHTAQ 2017 年 3 月 24 日
編集済み: FAHEEM MUSHTAQ 2017 年 3 月 24 日
Hi, Can you explain the code, how i find the repeat element location and replace automatic between the range 0-15. Suppose this is our matrix A= [15,11,11,15;,15,5,3,13;11,11,15,15;3,5,15,13], how we identify the repeated element in A and replace the range element on exactly location. Please explain the sequence of cammands/code. Thank you.

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

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by