HOW to create 4D array and 3D array

1 view (last 30 days)
SOHAN BISHT
SOHAN BISHT on 10 Mar 2020
Edited: James Tursa on 10 Mar 2020
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

Answers (1)

James Tursa
James Tursa on 10 Mar 2020
Edited: James Tursa on 10 Mar 2020
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.

Categories

Find more on Fortran with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!