HOW to create 4D array and 3D array

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Fortran with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by