Function Changem or substitute values of a matrix

Hello!
I am trying to use the function "changem" to substitute values from a matrix..(reference page: https://de.mathworks.com/help/map/ref/changem.html) I am using matlab 2017a but when I use the function, matlab says that the function is undefined.. I cannot find results when I search for it in the DOC.
Does this function still exists? When no, is there a equivalent function? Or does someone knows a possibility to change values of a matrix (is a little bit complex because I want to change the values of the matrix by an equivalent value of a vector).
Thanks in advance, MP

 採用された回答

Guillaume
Guillaume 2018 年 5 月 18 日
編集済み: Guillaume 2018 年 5 月 18 日

3 投票

As per sloppydisk's answer, changem requires the mapping toolbox, so clearly you don't have that installed.
I don't have the mapping toolbox either, but reading the function documentation, it seems trivial to implement:
function mapout = my_changem(mapout, newcode, oldcode)
assert(numel(newcode) == numel(oldcode), 'newcode and oldecode must have the same number of elements');
[toreplace, bywhat] = ismember(mapout, oldcode);
mapout(toreplace) = newcode(bywhat(toreplace));
end

1 件のコメント

MSP
MSP 2018 年 5 月 19 日
Thanks, works perfectly. After playing around sometime I did to manage it using 2 for loops and using if loops to check the constrains. But thanks again for the answer!

サインインしてコメントする。

その他の回答 (1 件)

sloppydisk
sloppydisk 2018 年 5 月 18 日

0 投票

changem is part of the Mapping toolbox, type
ver
to see which toolboxes you have installed.

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

MSP
2018 年 5 月 18 日

コメント済み:

MSP
2018 年 5 月 19 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by