Restructure column vectors into matixes

2 ビュー (過去 30 日間)
Nina Schuback
Nina Schuback 2020 年 5 月 4 日
回答済み: KSSV 2020 年 5 月 4 日
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.....

採用された回答

KSSV
KSSV 2020 年 5 月 4 日
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 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by