HOW to create 4D array and 3D array

1 回表示 (過去 30 日間)
SOHAN BISHT
SOHAN BISHT 2020 年 3 月 10 日
編集済み: James Tursa 2020 年 3 月 10 日
please help me to form 4D array for corresponding code of fortran REAL*8 C(-500:500,-500:500,1:4,1:4) and 3D array for REAL*8 C1(0:500,-500:500,1:4) in matlab

回答 (1 件)

James Tursa
James Tursa 2020 年 3 月 10 日
編集済み: James Tursa 2020 年 3 月 10 日
Fortran allows negative and 0 indexing, but MATLAB does not. There is no double class equivalent of this in MATLAB. You would have to create an array of the same size with positive indexing and manually adjust the indexing algorithms in your code. E.g., the Fortran code
REAL*8 C(-500:500,-500:500,1:4,1:4)
might be this in MATLAB
C = zeros(1001,1001,4,4);
and a Fortran indexing of C(-500,0,2,3) would be C(1,501,2,3) in MATLAB. I.e., Fortran C(i,j,k,m) becomes C(i+501,j+501,k,m) in MATLAB.
You could create a user-defined class to do this indexing adjustment, but it would take a bit of work and may not be worth it.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by