- FAQ
- doc mat2cell
- Why is the threed matrix bad? Why not just extract slices from it as necessary?
Extract columns of data from a 3D matrix and store each column as a new variable.
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I'm a graduate student who just started using MATLAB. I've created a 3D matrix and would like to extract each column from the matrix and store it as its own variable. The code describes the response from a dipole at different locations (lx, ly, lz) within the earth at different receiver locations(stn_locx(l),stn_locy,stn_locz) at the surface. In the 2D sections of the matrix, each column represents the dipole location (x,y) and the corresponding rows in the column are the responses for the receiver locations. The "pages" of the matrix represent different depths for the dipole.
lx=-487.5:25:487.5;
ly=0;
lz=-1000:25:-25;
stn_locx=-500:25:500;
stn_locy=0;
stn_locz=0;
for n=1:size(lx')
for k=1:size(lz')
for l=1:size(stn_locx')
for h=1:size(m')
[Bx(l,n,k), By(l,n,k), Bz(l,n,k)] = dipole_prim([stn_locx(l),stn_locy,stn_locz],lx(n),ly,lz(k),[1,0,0]);
end
end
end
end
I know this may be an easy thing to do, but not being familiar with matlab I've been struggling with this for a couple days.
Any help would be greatly appreciated!
Thanks,
Josh
댓글 수: 0
답변 (1개)
Sean de Wolski
2012년 6월 7일
You actually don't want to do this!
Welcome to MATLAB Answers!
댓글 수: 1
참고 항목
카테고리
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!