Extract columns of data from a 3D matrix and store each column as a new variable.

1 回表示 (過去 30 日間)
Joshua
Joshua 2012 年 6 月 7 日
コメント済み: brandon corwin 2022 年 10 月 29 日
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

回答 (1 件)

Sean de Wolski
Sean de Wolski 2012 年 6 月 7 日
You actually don't want to do this!
  1. FAQ
  2. doc mat2cell
  3. Why is the threed matrix bad? Why not just extract slices from it as necessary?
Welcome to MATLAB Answers!
  1 件のコメント
brandon corwin
brandon corwin 2022 年 10 月 29 日
Why comment if you aren't going to provide a useful answer?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by