How to make two column vectors from cell vector with space delimiter?

3 vues (au cours des 30 derniers jours)
Sanket Gaikwad
Sanket Gaikwad le 30 Juin 2020
Commenté : Sanket Gaikwad le 30 Juin 2020
I've one cell vector (3000by1) and I'm trying to make this into two column vectors.
C= '2020-06-29 11'
'2020-06-29 11'
'2020-06-29 11'
'2020-06-29 11'
'2020-06-29 11'
I want to seperated date and hour (11 is hour value here).

Réponse acceptée

madhan ravi
madhan ravi le 30 Juin 2020
S = regexp(C, '\s', 'split');
s = cat(1, S{:});
datE = s(:,1)
HouR = s(:,2)
  3 commentaires
madhan ravi
madhan ravi le 30 Juin 2020
C= {'2020-06-29 11'
'2020-06-29 11'
'2020-06-29 11'
'2020-06-29 11'
'2020-06-29 11'}
S = regexp(C, '\s', 'split');
s = cat(1, S{:});
datE = s(:,1)
HouR = s(:,2)
C =
5×1 cell array
{'2020-06-29 11'}
{'2020-06-29 11'}
{'2020-06-29 11'}
{'2020-06-29 11'}
{'2020-06-29 11'}
datE =
5×1 cell array
{'2020-06-29'}
{'2020-06-29'}
{'2020-06-29'}
{'2020-06-29'}
{'2020-06-29'}
HouR =
5×1 cell array
{'11'}
{'11'}
{'11'}
{'11'}
{'11'}
Sanket Gaikwad
Sanket Gaikwad le 30 Juin 2020
Thank you very much, it worked. The data I was working on had different last two rows. I guess that was the reason it was showing me that error.

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by