Create a new matrix from a mapping process
3 ビュー (過去 30 日間)
古いコメントを表示
I have mapped a set of numbers to a list of strings for example
KS = {'A','B','C'}; VS = [1:3]; x = containers.Map(KS,VS);
I have a 1 coloumn vector that looks like this
'A' 'B' 'B' 'C' 'A'
I want to create a new matrix which maps the letters to their respective numbers - so this would return 1 2 2 3 1
many thanks
0 件のコメント
採用された回答
Andrei Bobrov
2013 年 4 月 18 日
編集済み: Andrei Bobrov
2013 年 4 月 18 日
Vin = {'A' 'B' 'B' 'C' 'A'};
return1 = [Vin{:}] - 'A' + 1;
or
KS = {'A','B','C'};
VS = [1:3];
Vin = {'A' 'B' 'B' 'C' 'A'};
[~,ii] = ismember(Vin,KS);
out = VS(ii);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interpolation of 2-D Selections in 3-D Grids についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!