MATLAB Answers

arrange the values in an array

3 views (last 30 days)
Hassan
Hassan on 29 Apr 2011
I have an array A(80 rows and 5 columns). I want to export it as a table to microsoft word as the values in A (i:i+4,j)are placed in one cell with no cell line between them. Not sure if it's possible in Matlab.
  3 Comments
Andrei Bobrov
Andrei Bobrov on 29 Apr 2011
agree or Excel or textfile.txt

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 29 Apr 2011
in Excel
xlswrite('namexls',cellfun(@(x)num2str(x.'), mat2cell(A,5*ones(size(A,1)/5,1),ones(1,size(A,2))),'UniformOutput' , false),1,'A1');
  1 Comment
Hassan
Hassan on 29 Apr 2011
thanks a lot Andrei, this is the thing I was looking for. however, the values in each cell are arranged horizontally while I want to arrange them vertically. I sthere any way to transpose the data in each cell?

Sign in to comment.

More Answers (1)

Friedrich
Friedrich on 29 Apr 2011
Or you can use Word as Com Server. I prepared a little example for you:
e = actxserver('Word.Application')
e.visible = 1
doc = e.newDocument.Application.Documents.Add
doc.Content.InsertAfter('text')
  1 Comment
Hassan
Hassan on 29 Apr 2011
thanks Friedrich. It's a good example to see how can have access to Word from Matlab.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!