How can a chemical structure be stored in a matrix? How do I represent a chemical structure in a matrix format in Matlab? Can I input a chemical structure into Matlab using the S.M.I.L.E.S notation?

I have to specify the connectivity of different atoms with others and type of bonds between them. I have to write the structure in matrix form, so that it can be utilized in some linear programming. For example, if one atom is connected to another atom I have to store 1 in matrix otherwise 0 (binary variables).
I need to develop back end code for my purpose to design some molecules using this approach. As of now I am dealing with 2D structures.
Are the use of MATLAB (or OCTAVE) and a self-designed molecular representation mandatory for you project? 

Established 2D- and 3D representations for molecules beyond a connectivity matrix, i.e. with coordinates, (partial) charges, annotation of isotopes, etc. exist, such as in the form of the Chemical Markup Language (CML).

In addition, well-documented toolkits, frameworks and modules are available to operate on these data are available for C++, Java, Perl, Python, and Ruby.