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!