Hi Usman,

I am not very familiar with matlab syntax -- but it appears you want to execute these statements to produce an array in Mathematica, as they would in Matlab. This is possible because of course both systems define array and the means of setting element values. However, the syntax differs. We need to translate the Matlab syntax to Mathematica.

Mathematica defines arrays and higher order tensors as lists of lists. Matlab appears to use a single square braket set to designate an element part, but Mathematica uses a double bracket. In Mathematica, the third row second element of the matrix m is given as m[[3,2]] or m[[3]][[2]]. So we need this translation. Also, the underscore is a reserved character used in pattern definitions, so it must be eliminated.

The below code does both of these things, which translates the statements. Then it defined a matrix with default values, here 0, but they could be anything including Null. It then executes the statements by interpreting the translated strings as input.

I give the code below. The output has been deleted so you get something you can cut and paste. If you paste this into a notebook and execute it, it will reproduce the result. By dividing the lines and removing semicolons you can see each output as it executes. There may well be a more elegant way to do this, but this works. At least as long as the input so constructed from the rest of your data produces valid code.

(* set the file name *)

fileName = "C:\\Users\\David\\Documents\\Mathematica \

Files\\import\\data2.txt";

(* read the file as a list of strings *)

raw = ReadList[fileName, String];

(* change the syntax to mathematica *)

executable = StringReplace[raw, {"_" -> "u", "[" -> "[[", "]" -> "]]"}];

(* define kue as a 4x4 array with default values *)

kue = Table[0, {4}, {4}];

(* execute the translated expressions *)

ToExpression /@ executable;

kue // TableForm