Converting 2-d[:,45] matrix to 3-d[:,45,246] matrix based on unique values in 2nd column of 2d matrix
1 次查看(过去 30 天)
显示 更早的评论
I have a 2-d matrix with [:, 45] dimension, which I want to convert into a 3-d matrix of dimension [:,45,246] based on 246 unique values on 2nd column of 2-d matrix.
3 个评论
回答(1 个)
Walter Roberson
2018-5-10
[uniquevals, ~, idx] = unique(YourMatrix(:,2));
for J = 1 : length(YourMatrix,1)
NewMatrix(J, :, idx(J)) = YourMatrix(J, :);
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!