How to change matrix dimensions?
14 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a question regarding a 3D matrix with portfolio returns.
I have a 10000x35x12, which is 10000 simulated return paths for 35 years and 12 months in each year. Now I want to make this a 2D matrix with dimensions 10000x420 (35x12) such that the 420 months of return are in the right order. Can somebody help me with that?
Thanks in advance!
Greetz
0 个评论
回答(4 个)
Andrei Bobrov
2012-12-6
M - your 3D array with size < 10000,35,12 >
out = reshape(permute(M, [1 3 2]),size(M,1),[]);
0 个评论
Azzi Abdelmalek
2012-12-6
[n,m,p]=size(A)
b=reshape(A,n,p*m)
idx=reshape(1:p*m,m,p)'
out=b(:,idx(:))
0 个评论
另请参阅
类别
在 Help Center 和 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!