Seems I am not good at either FORTRAN or MATLAB while knowing a little bit about both of them.
While I found MATLAB is good at handling matrices, I also found implicit interface in a fortran program is rather convenient (I can pass claimed variables, especially some large arrays, to implicit functions without put them as input dummy arguments, and also I can pass variables claimed in the interface back to the calling program easily).
I am just wondering whether there is any similar mechanism in MATLAB as implicit interface so that I can do the work as I do with FORTRAN. (Global variable seems not very good since, if I try to call the function often, it would just turned to a tedious work -- maybe I am wrong)
What's your opinion? Thanks.
Here is an example:
PROGRAM test_function
IMPLICIT NONE
REAL :: A, B
REAL :: C,D,E
A = 1
B = 2
D = 3
E = xf(A)-A
WRITE (*,*), "A = ", A
WRITE (*,*), "B = ", B
WRITE (*,*), "C = ", C
WRITE (*,*), "D = ", D
WRITE (*,*), "E = ", E
CONTAINS
FUNCTION xf(x)
IMPLICIT NONE
REAL, INTENT(IN) :: x
REAL :: xf
C = x+B
D = x+D
xf = A+B+C
END FUNCTION xf
END PROGRAM test_function
D is passed into the Function xf(·) without being taken as a dummy argument, and D could also be passed out with no restrictions. The result given by the program is as follows:
A = 1.0000000
B = 2.0000000
C = 3.0000000
D = 4.0000000
E = 5.0000000