Need Help Urgent!!!!!!!!!!!!
Mostrar comentarios más antiguos
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 comentarios
Matt Fig
el 28 de Mzo. de 2011
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
el 28 de Mzo. de 2011
And what if the last element, or the last three elements are 33? Do we add an element?
Amir Hamzah UTeM
el 28 de Mzo. de 2011
Amir Hamzah UTeM
el 28 de Mzo. de 2011
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Multidimensional Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!