table with NaNs into separate cells
5 ビュー (過去 30 日間)
古いコメントを表示
I have a table (M) with 4 columns (columns named X, Y, Z,K) , there is a break between the data that loads as NaN.
I want place each data chunk into cells with all 4 columns (X, Y, Z,K).
Thank you!
0 件のコメント
採用された回答
Voss
2024 年 4 月 24 日
% making a table with some all-NaN rows:
Var = randi(100,12,4);
Var([3 9],:) = NaN;
M = array2table(Var)
% split the table on the all-NaN rows into a cell array of tables:
idx = find(all(isnan(M{:,:}),2));
s_idx = [1; idx+1];
e_idx = [idx-1; size(M,1)];
result = arrayfun(@(s,e)M(s:e,:),s_idx,e_idx,'UniformOutput',false)
celldisp(result)
10 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!