How can I return cell array values using an index matrix.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Aaron Jean-Baptiste
il 1 Ott 2017
Commentato: Walter Roberson
il 2 Ott 2017
Hi there,
I have the following variables:
variableNames = {'Aaron', 'Brett', 'Charlie', 'Katie', 'Jess'}
index_matrix = [1,3,4,5,2; 2,1,4,5,3; 3,2,1,5,4]
and I want to return the variableName corresponding to that index in a new cell array or timetable:
index_name = {'Aaron','Charlie','Katie','Jess','Brett';
'Brett','Aaron','Katie','Jess','Charlie';
'Charlie','Brett','Aaron','Jess','Katie'}
My index_matrix is actually in a timetable, but I suppose once I have a solution for this I can adjust it.
Many thanks,
Aaron
0 Commenti
Risposta accettata
Walter Roberson
il 1 Ott 2017
index_name = variableNames(index_matrix);
3 Commenti
Walter Roberson
il 2 Ott 2017
timeseries() does not appear to be usable for cell array of strings.
You could convert to categorical... which would effectively look like your index matrix internally.
You could create a timetable() if you have a sufficiently new MATLAB.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Tables 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!