user552231
user552231

Reputation: 1135

How to write a cell of strings to Excel in Matlab?

I am trying to write a short function that will take a cell of strings and will write it as is to Excel:

Excel = 

'r2g'    'r3g'    't2g'    't3b'    'c3b'    'r1r'    'r1g'    'r3r'    't3g'    't1r'
't1b'    't2b'    't3r'    'c1r'    't3g'    'r2b'    'r1g'    'c3b'    'c2b'    'c1b'
'c3r'    'c3g'    't2r'    'c1b'    'r1g'    'r1b'    'r3b'    'c1r'    't1r'    'r1r'
't3b'    'r2r'    't1r'    'r1r'    't3r'    't1g'    'r3r'    'r2g'    'c1r'    'r1g'
'c1g'    'r2g'    'r3r'    'r2b'    'c3r'    'c3b'    'c1b'    'r3g'    't1g'    't3r'
't1r'    'r2b'    'r3r'    't3g'    'r1g'    'c2g'    'r2g'    't1b'    'c1b'    'c1r'
'c3b'    't1r'    'r3b'    'r1r'    'r2r'    'c1b'    'c2g'    'c2b'    't1b'    'r2g'
'r2b'    'c3b'    't2g'    'c2r'    'c1b'    'c1g'    't3b'    'c2b'    'c3r'    't1r'
't3r'    't1r'    'r1r'    't2b'    'r3r'    'r1b'    't3b'    'c3g'    'c3b'    'r1g'
'r3b'    't2g'    'r2r'    'r1r'    't3b'    'c3b'    'c1r'    'r2g'    't1r'    'c2r'

I want each triplet to be in a different cell in Excel. I looked at the answers here regarding the strings array but they didn't work for me.

Upvotes: 0

Views: 2972

Answers (1)

feralcreature
feralcreature

Reputation: 106

You can just use the xlswrite function:

xlswrite('filename.xls', yourMatrix);

Edit: This function can accept either a matrix or a cell array. Thanks to commenters for pointing that out.

Upvotes: 1

Related Questions