Detect change between two values in an array
이전 댓글 표시
Is there any function in Matlab that allows you to read through a column in an array and see if a previous value is the same as a current value? I know there is the "detect change" function block in Simulink and was looking to do something similar with code, however.
채택된 답변
추가 답변 (1개)
Image Analyst
2013년 10월 1일
Try this:
x=[ 0 0 4 5 7 3 3 87 2 5 1 1]
changedIndexes = diff(x)~=0
댓글 수: 6
Muneer
2013년 10월 3일
Gervasio Batista
2017년 12월 1일
Could you extend this to an cell array, please? Thank you!
Brandon Leonard
2018년 4월 30일
Could you extend this to an cell array, please? Thank you!
Image Analyst
2018년 5월 1일
Use cell2mat() on your cell array first.
Nikolaos Vasilas
2018년 8월 25일
what if the table has nan values?
Image Analyst
2018년 8월 25일
Table variables can be nan, just like double variables. Actually a column of a table has to be a predetermined type, like double, char, int32, or whatever. So if a column is double, then it's allowable for a row in that double column to have a value of "nan".
카테고리
도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!