To replace values in a vector with another value in Matlab, you can use indexing.
For example, let's say you have a vector x
that contains the following values:
main.m17 chars2 lines
If you want to replace all occurrences of the value 2 with the value 0, you can do the following:
main.m15 chars2 lines
This code will find all indices in the vector where the value is equal to 2, and replace those values with 0.
Similarly, you can use the same indexing technique to replace any value in the vector with another value.
gistlibby LogSnag