Converting symbols in columns to different numeric values
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I need some help converting symbols in a matrix to integers. The thing is, I need eveery symbol to be a different value based on what column it is in. This is what I have so far:
%permutations
syms BUF TB TEN GB
picks1 = [BUF TB TEN GB];
orders1 = perms(picks1);
This outputs a matrix with all of the possible permutations of those four symbols.
I'd like to convert them to integers, but with the symbol meaning something different when it's in each column. i.e. for column 1 GB = 45, TB = 127, TEN = 128, KC = 131, for column 2 GB = 29, TB = 60, TEN = 64, KC = 71, etc.
Is there any way to do this easily using matlab?
Thank you in advance!
0 件のコメント
回答 (1 件)
Walter Roberson
2022 年 1 月 20 日
syms GB KC TB TEN
picks1 = [GB TB TEN KC];
orders1 = perms(picks1);
GBv = [45; 29; 18; 7];
TBv = [127; 60; 34; 11];
TENv = [128; 64; 37; 13];
KCv = [131; 71; 38; 14];
temp = arrayfun(@(K) subs(orders1(:,K), picks1, [GBv(K), TBv(K), TENv(K), KCv(K)]), 1:size(orders1,2), 'uniform', 0);
output = [temp{:}]
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!