필터 지우기
필터 지우기

multidimensional matrix

조회 수: 2 (최근 30일)
scour_man
scour_man 2011년 6월 14일
[EDIT: 20110614 09:54 CDT - reformat - WDR]
I have a matrix dep(time,lat,lon), shape=[5 20000 30000]
The matrix is data from 5 years worth of hydrographic surveys and each survey contains data for depth at position lat and long. I already have the matrices for lat and lon as separate variables: lat [20000x1 double] and lon [30000x1 double]
The five layers of the dep matrix correspond to survey data each year from 2000 to 2004. What I would like to do is be able to 'extract' data from just one year so that I can do a contour(lat,lon,depth) plot for that year.
I am still learning the ropes with Matlab, any help would be much appreciated. Thank you!
  댓글 수: 1
scour_man
scour_man 2011년 6월 14일
I think I figured it out, I did
dep2000=dep(1,:,:);
dep2000=reshape(dep2000,20000,30000);
surf(lat,lon,dep2000)
is this right?

댓글을 달려면 로그인하십시오.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 6월 14일
Hi,
using reshape works, but what you want to do, is to get rid of the first dimension (i.e., changing your 1x20000x30000 matrix to a 20000x30000 matrix). This is done using squeeze:
dep2000 = squeeze(dep(1,:,:)); % should be 20000x30000
surf(lat, lon, dep2000);
Titus
  댓글 수: 1
scour_man
scour_man 2011년 6월 14일
great thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by