How can I add new column in a dataset array but not at the end?
古いコメントを表示
I have a dataset array [202x89] and another one [150x97]. I want to Concatenate arrays but they must have the same number of variables and All datasets in the bracketed expression must have the same variable names. The new columns that i want to insert in the first dataset i want to be 'NaN'. That's ok but but i want to specify the position of a new column (to use after all the vertcat function). Can you help me please.
Thanks
採用された回答
その他の回答 (1 件)
David Young
2012 年 1 月 17 日
To insert a column of NaNs after column c of matrix A, you could use
Anew = [A(:,1:c) NaN(size(A,1),1) A(:, c+1:end)];
To insert k columns of NaNs after column c, use
Anew = [A(:,1:c) NaN(size(A,1),k) A(:, c+1:end)];
2 件のコメント
alexis
2012 年 1 月 17 日
David Young
2012 年 1 月 18 日
You didn't say that dataset is a class of the Statistics Toolbox. I can't help with that.
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!