Need Help Urgent!!!!!!!!!!!!
이전 댓글 표시
i have this data in matrix X=[22,33,11,33,33,33,22]
i want to change the data with this form of matrix X=[22,33,22,33,33,33,44]
i have to follow this rules: 1)when find(X==33) next data must change into 22 2)when there have data "33" three times in row,the next data must change to 44
this is my example code for the looping: [a b]=find(X==33)
if X(a,b+1)-X(a,b)==1 if X(a,b+2)-X(a,b+1)==1 X(a,b+3)=44 end end
if X(a,b+1)-X(a,b)==2 X(a,b+2)=22 end
i know im doing this all wrong,can someone give a correct algorithm to get the answer that satisfied the rules.
Amir my email: noksworld@yahoo.com
댓글 수: 4
Matt Fig
2011년 3월 28일
Your rules conflict and don't cover all possible cases (at least for a random X). What if there are two 33's in a row? Do we change the second one to a 22? What if there are four 33's in a row? Do we change the last one to a 44, or the element after the four 33's? Please clarify.
Matt Fig
2011년 3월 28일
And what if the last element, or the last three elements are 33? Do we add an element?
Amir Hamzah UTeM
2011년 3월 28일
Amir Hamzah UTeM
2011년 3월 28일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!