Converting symbols in columns to different numeric values
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 20 Gen 2022
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{:}]
Vedere anche
Categorie
Scopri di più su Number Theory in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!