selectively replace elements in vector
Show older comments
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 Comments
Walter Roberson
on 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
on 23 Jan 2013
Walter Roberson
on 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
on 23 Jan 2013
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!