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!

回答(1 个)

Walter Roberson
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{:}]
output = 

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by