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.

3 次查看(过去 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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by