extract sub matrix of sub matrix directly
3 次查看(过去 30 天)
显示 更早的评论
I have matrix a m-by-n-by-p.
b=a(:,:,1) is a sub matrix of a.
I want to extract sub matrix of b (say c) so that
c=b(1:4, 1:4)
Can I extract c from matrix a such as
c=[a(:,:,1)](1:4, 1:4) This means
c=b(1:4, 1:4)
With regards -Abhijit
0 个评论
采纳的回答
更多回答(1 个)
Dr. Seis
2012-3-20
You will have to use reshape if you take a sub-set a different way, e.g.:
>> a = rand(3,3,3);
>> b = a(1:2,1:2,1)
b =
0.3922 0.7060
0.6555 0.0318
>> b = a(1:2,1,1:2)
b(:,:,1) =
0.3922
0.6555
b(:,:,2) =
0.6948
0.3171
>> b = reshape(a(1:2,1,1:2),[2,2])
b =
0.3922 0.6948
0.6555 0.3171
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!