selectively replace elements in vector
显示 更早的评论
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 个评论
Walter Roberson
2013-1-23
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
2013-1-23
Walter Roberson
2013-1-23
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
2013-1-23
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!