How I can detection column indexes of string 'rk_accept_metaln' (n=1,2,3,4....)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Chao Zhang
le 9 Déc 2021
Réponse apportée : Stephen23
le 9 Déc 2021
I want to use the folloing code to automatic detection column indexes of 'rk_accept_metaln'(n=1,2,3,4,...n)
For example, run the following code, if the num=1, then the column index of rk_accept_metal1' is 9 (i.e. col_ind=9)
Then, the num >1, like num=2, we should get the column indexes of r1 and r2 (i.e col_ind=[9,11]) if running the code
%Determine the column index of variable names
match_var1 = str2double(regexp(var_nm.Properties.VariableNames, '(?=rk_accept_)+((?<=^metal)\d)$','once','match'));
ind_rmg = find(match_var1 <= num1);
But i cannot get anything if i use this code, i think the point is '(?=rk_accept_)+((?<=^metal)\d)$', but i have no idea how to fix it
Thanks in advance for help!
2 commentaires
Mathieu NOE
le 9 Déc 2021
hello
it could be helpful if you share the input data as well (var_nm.Properties.VariableNames)
Réponse acceptée
Stephen23
le 9 Déc 2021
C = {'X','Y','Z','X_size','Y_size','Z_size','volume','block_tonnage','rk_accept_grade1','rk_accept_metal1','rk_rejected_grade1','rk_rejected_metal1','rk_accept_grade2','rk_accept_metal2','rk_rejected_grade2','rk_rejected_metal2','rk_accept_tonnage','rk_rejected_tonnage','sg','volume_factor'};
N = str2double(regexp(C, '(?<=rk_accept_metal)\d+$','once','match'))
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!