Extracting along a dimension in a 4D array

조회 수: 7(최근 30일)
Prerna Mishra
Prerna Mishra 2022년 6월 30일
댓글: KSSV 2022년 6월 30일
I have a 4D array of dimsension na*nk*nkprime*nd, each dimension representing, number of shock, number of capital today, number of capital tomorrow and number of debt recently. na = 11, nk = 121, nkprime = 121 and nd = 51. I was to extract the values from nk and nkprime positions when na = 2 and nd = 1;
I am doing the following:
V = Rmat(2,:,:,1)
Is this correct?

채택된 답변

KSSV
KSSV 2022년 6월 30일
YEs, it is correct. When you extract you will get 1x121x121 array. You may remove the extra dimension using squeeze.
na = 11; nk = 121 ; nkprime = 121 ; nd = 51 ;
A = rand(na,nk,nkprime,nd) ;
iwant = squeeze(A(2,:,:,1)) ;
  댓글 수: 2
KSSV
KSSV 2022년 6월 30일
A 2D array can be plotted using pcolor, surf

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

추가 답변(0개)

범주

Find more on Data Type Conversion in Help Center and File Exchange

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by