MatLab to Excel

Sometimes I have trouble visualizing some matrix structures that I create in MatLab. And when I get to see them in the MatLab command line or the matlab workspace it does not help much. A way to deal with that and seek and understand patterns easier is to export them in excel. MatLab supports this with the instructions:

xlsread (to read from an excel file) and

xlswrite (to write to one)

the parameters that follow are:

(filename, matrix(to be written max 2 dimensions), sheet, range)

by using the following one can create matrixes that contain both data and titles:

matrix1 = {‘Title1', Title2'; 1 423 ; 2 742; 3 192}

And to actually write in an excel file:

xlswrite('matrix1.xls', matrix1, 'Example Sheet', 'E1')

It is needless to point out the usefulness of this. One can either import data to MatLab from an excel (which amy be automated to produce desired data and easily editable) and once the simulation is done and the results are calculated they can be exported for further analysis in an excel too.

Both tools are very powerful mathematical tools each one with different properties. The combination of these both can really give solutions to many problems!

Advertisements