Extracting first element of multiple arrays within a cell

Hello,
I have a cell name zz with 1x6 of datetime . And inside of zz are with YYYY-MM-DD hh:mm:ss.SSS forma. I want to create a variabe which consist of the first elements datetime value of zz of all 6 columns. I am trying and I am stucked with it. Can someone help me?

 Réponse acceptée

result = cellfun(@(c) c(1), zz)

6 commentaires

Marcel
Marcel le 8 Nov 2022
Déplacé(e) : Voss le 8 Nov 2022
if i get it right and you just want to select values from this "table", its showing you on how to access them.
uzzi
uzzi le 8 Nov 2022
Déplacé(e) : Voss le 8 Nov 2022
hello, i want to access of the first element from zz{1,1} to zz{1,6}.
Marcel
Marcel le 8 Nov 2022
Déplacé(e) : Voss le 8 Nov 2022
should work with zz{1:6} or zz(1:6). the way matlab uses brackets etc confused me from time to time. best way to learn is to experiement
explaination would be nice as i didnt use that myself too yet sooooo. would love to know and others for sure too
Thank you. It works.
Jan
Jan le 8 Nov 2022
Déplacé(e) : Voss le 8 Nov 2022
As far as I understood, this is wanted: [zz{1}(1), zz{2}(1), zz{3}(1), etc.]

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by