AmiBroker 6.00 has introduced support for matrices. After we create a matrics with Matrix function call:<\/p>my_var_name <\/span>= <\/span>Matrix<\/span>( <\/span>rows<\/span>, <\/span>cols<\/span>, <\/span>initvalue<\/span>)<\/code>
then in order to access matrix elements, we need to use:
x <\/span>= <\/span>my_var_name<\/span>[ <\/span>row <\/span>][ <\/span>col <\/span>]<\/code>
However – if we want to populate a relatively large matrix with values generated in other programs, then it may not be very practical to do it by hand in the AFL code assigning individual elements like this:<\/p>
A<\/span>[ <\/span>0 <\/span>][ <\/span>0 <\/span>] = <\/span>1<\/span>; <\/span>A<\/span>[ <\/span>0 <\/span>][ <\/span>1 <\/span>] = <\/span>4<\/span>; <\/span>A<\/span>[ <\/span>0 <\/span>][ <\/span>2 <\/span>] = <\/span>6<\/span><\/code>
What we can do in such case is to store the values in a text file that we could use as input, then read through the file using fgets<\/strong> function and populate Matrix elements using a looping code. A sample formula showing how to perform such task is presented below.<\/p>