Restructure column vectors into matixes
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a .mat file with several variables, one of them date. The data in all variables are in a one column vector and correspond to each other.
I would like to restructure each vector into a matrix based on the date vectror, i.e. the unique values in the date vector will become one column each, and the same for all other variables.
There must be a easy solution to this using the unique function, but I cannot figure it out.....
0 commentaires
Réponse acceptée
KSSV
le 4 Mai 2020
Let dates be your date and A be your column vector whcih you want to reconstruct.
[C,ia,ib] = uniqur(dates) ; % if this dont work convert dates to datenum
N = length(C) ;
iwant = cell(N,1) ; % cell becuase there is no rule that there will same number of elements to frame matrix
for i = 1:N
iwant{i} = A(ib==i) ;
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time 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!