selectively replace elements in vector
Afficher commentaires plus anciens
I need to replace some of the values in a vector example
a = [ 2 2 2 2 3 3 3 3 7 7 4 4 4 4 4 7 7 7 7 7 7 1 1 1 ]
I need to replace only the 7's occurring between 3 and 4 , and put 3 or 4 there
thanks in advance.
4 commentaires
Walter Roberson
le 23 Jan 2013
If there was [3 7 1 5 9 4] then would the 7 be counted as being between 3 and 4 ?
You have as a sublist, [3 7 7 4]. Is either 7 counted as being between 3 and 4? The first 7 is between 3 and 7, and the second is between 7 and 4.
Which are you wanting to put in, 3 or 4 ?
Srinivas
le 23 Jan 2013
Walter Roberson
le 23 Jan 2013
So if you have one or more 7's that is immediately preceded with a 3 and immediately followed by a 4, then the 7's are all to be changed to 4's ?
Srinivas
le 23 Jan 2013
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!