Restructure column vectors into matixes
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!