Restructure column vectors into matixes

2 visualizaciones (últimos 30 días)
Nina Schuback
Nina Schuback el 4 de Mayo de 2020
Respondida: KSSV el 4 de Mayo de 2020
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.....

Respuesta aceptada

KSSV
KSSV el 4 de Mayo de 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

Más respuestas (0)

Categorías

Más información sobre Time Series Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by