qickyly change 3D matrix to 2D matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, This might be such a silly question but could anyone please help? I get a 3D matrix A(n,m,k) so I want to take the value a(:,1)=A(1,1,:). But Matlab doesn't allow me to do that. Is using "for" loop the only way to do that?
댓글 수: 0
채택된 답변
Roger Stafford
2017년 2월 16일
편집: Roger Stafford
2017년 2월 16일
You could accomplish that with:
a = reshape(permute(A,[3,1,2]),size(A,3),[]);
[Note: You really haven’t specified how the first two dimensions in A should be arranged in the single second dimension of a. Here I have taken the default arrangement.]
댓글 수: 0
추가 답변 (1개)
Rahul Kalampattel
2017년 2월 16일
For the example you gave, the following also works:
a=squeeze(A(1,1,:));
댓글 수: 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!