Let's look at your code to understand the problems and identify what it does and doesn't do.
This may enable you to develop the Matlab code you want.
I don't think you'll get much help from this forum in doing a translation.
Formatting the so you have each sub-statement on a single line will help you understand it a bit better:
defvar := Module[{a},
Clear[cN, cNf, ginix];
Clear[Nh, Nhf, gini];
cN = Array[Nh, dim];
cNf = Array[Nhf, dim];
ginix = Array[gix, steps];
]
defvar := ... defines a bespoke function and the left side of an expression.
In the code defvar has no parameters passed to it, which it could if you have code something like the following, which enables one to pass 3 parameters to the function:
defvar[x_, y_, z_]:= something...
Everything within the right side of the expression resides in the native Mathematica function Module, which ring fences the variable shown with the curly brackets {a}.
First problem, the function defvar doesn't use a for anything. It has a local variable, but it doesn't use it.
Next, you have two statements which use Clear:
Clear[cN, cNf, ginix];
Clear[Nh, Nhf, gini];
These statements clear the value of the six listed variables: cN, cNf, ginix,Nh, Nhf, and gini. First thought, these look like global variables in a Notebook, but they could also reside in i.e., a higher level function or Module.
The code then assigns values to the "global varialbescN, CNf, and ginix.
Since the code, preceding these value assignments, clears Nh, Nhf, and ginix the assignments for these variables appear to only assign symbolic values.
The code posted does not have any internally received or generated values for dim or steps or gix.
fix would set symbolically, but unless the defvar function can access integers for dim and steps the array generation won't work.
dim and steps may exist as global variable in some larger code.
Finally, while the defvar function may do something in the right larger environment, it does not return anything. It has no output.
As example...
defvar := Module[{a},
Clear[cN, cNf, ginix];
Clear[Nh, Nhf, gini];
cN = Array[Nh, dim];
cNf = Array[Nhf, dim];
ginix = Array[gix, steps]
]
notice that I removed the last semicolon in the code. This would enable the function to return the defined array, ginix.
Another possibility...
Something like the following would enable it to output all of the defined arrays:
defvar := Module[{a},
Clear[cN, cNf, ginix];
Clear[Nh, Nhf, gini];
{
cN = Array[Nh, dim],
cNf = Array[Nhf, dim],
ginix = Array[gix, steps]
}
]
but it's hard to speculate about what you want to do without more information.