extracting the second column of all cells of a struct
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sahar khalili
le 11 Oct 2022
Commenté : Sahar khalili
le 12 Oct 2022
I have a struct, x1_surf, that contains 1070 cells, each cell has 4 cells, now I want to extract the second column of the inner cells with the order.
This is x1_surf
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152393/image.png)
This is the x1_surf{1,1}
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152398/image.png)
now, I want to extract the second column of all inccer cells with the correct order, I mean x1_surf{1,:}{1,2}
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152403/image.png)
I write a script like that:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152408/image.png)
It works correcly for some files, however for some other files, the order of the date is mixed up and they are not in the right order. Could anyone help me how I can rewise it?
1 commentaire
Stephen23
le 11 Oct 2022
You should replace all of the nested 1x4 cell arrays with TIMETABLEs or TABLEs.
Réponse acceptée
David Hill
le 11 Oct 2022
for k=1:length(x1_surf)
x2_surf{k}=x1_surf{k}{2};
end
5 commentaires
David Hill
le 12 Oct 2022
I am assuming you just want just one listing of all the date-times.
load('x1_surf.mat');
x2_surf=[];
for k=1:length(x1_surf)
x2_surf=[x2_surf;x1_surf{k}{2}];
end
x2_surf(1:20)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion 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!