{"id":1194,"date":"2015-09-26T05:44:21","date_gmt":"2015-09-26T10:44:21","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=1194"},"modified":"2015-10-01T05:47:40","modified_gmt":"2015-10-01T10:47:40","slug":"how-to-populate-matrix-from-a-text-file","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2015\/09\/26\/how-to-populate-matrix-from-a-text-file\/","title":{"rendered":"How to populate Matrix from a text file"},"content":{"rendered":"
AmiBroker 6.00 has introduced support for matrices. After we create a matrics with Matrix function call:<\/p> then in order to access matrix elements, we need to use: 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>my_var_name <\/span>= <\/span>Matrix<\/span>( <\/span>rows<\/span>, <\/span>cols<\/span>, <\/span>initvalue<\/span>)<\/code>
x <\/span>= <\/span>my_var_name<\/span>[ <\/span>row <\/span>][ <\/span>col <\/span>]<\/code>
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>