Extract Tables from within a cell
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
HabenG
le 27 Nov 2021
Réponse apportée : Walter Roberson
le 27 Nov 2021
I have a bunch of tables saved within a cell, each table with two columns. How do i extract each table from the cell?
The table is attached.
0 commentaires
Réponse acceptée
Plus de réponses (2)
KSSV
le 27 Nov 2021
load('Tables.mat');
T = cellfun(@table2array,Tables,'UniformOutput',false) ;
iwant = cell2mat(T') ;
0 commentaires
Walter Roberson
le 27 Nov 2021
Tables{1}
Tables{2}
and so on.
If you wanted to put the results together into a cell array so that you could work with this in a loop or something like that... then the cell array would be exactly the same as what you already have.
I have the suspicion that you want to extract them into individual variables and that you want that done automatically no matter how many entries are in the cell. If so... don't . http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
If you are fixed to exactly 7 entries, then you could use
[T1, T2, T3, T4, T5, T6, T7] = Tables{:};
... but you probably shouldn't... at least not unless you have better names available. Perhaps
[flux_monday, flux_tuesday, flux_wednesday, flux_thursday, flux_friday, flux_saturday, flux_sunday] = Tables{:};
Something like that would be reasonable.
0 commentaires
Voir également
Catégories
En savoir plus sur Logical 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!