Given a numerical array A and two arrays From and To of equal size, we would like to make substitution From(i)->To(i) in the array A for every i.
If the number of values to substitutes (numel(From)) is small, one can use a vectorized code to substitute the values one-by-one. However, this is too costy if there are too many substitutions. In this case, the provided function uses a different algorithm. It sorts the array A and the substitution rules and then it does one non-vectorized sweep of the inputs. Finally, we restore the original order and shape of A.
引用格式
Ondrej Budac (2026). fast array substitution (https://ww2.mathworks.cn/matlabcentral/fileexchange/47101-fast-array-substitution), MATLAB Central File Exchange. 检索时间: .
