MATLAB Answers

Function to check whether an array contains a duplicate of elements

조회 수: 4(최근 30일)
Mina 2021년 7월 11일
댓글: dpb 2021년 7월 12일
I want to write a function that
- Takes as input an array, the value being checked and the starting element of the array where checking for a duplicate should start
- Returns a logical value to indicate whether the array contains a duplicate of the value being checked (stops checking when one is found)
  댓글 수: 2

댓글을 달려면 로그인하십시오.


dpb 2021년 7월 11일
편집: dpb 2021년 7월 12일
function flag=isduplicate(x,v,ix)
x is vector or if x is array in linear addressing order.
Otherwise, need indexing expression of row, colum, ... for as many dimensions as are greater > 1 in size(x)
If x is floating point, then for robustness, consider ismembertol instead of exact equality or write a tolerance expression.
  댓글 수: 2

댓글을 달려면 로그인하십시오.


Community Treasure Hunt

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

Start Hunting!

Translated by