How to write2 strings in a cell in Excel ?

1 回表示 (過去 30 日間)
andrea
andrea 2014 年 11 月 5 日
コメント済み: andrea 2014 年 11 月 5 日
This are 2 cell-array:
a={'Hi';'Hi'}; b={'Fred';'Alex'};
I would like to combine each row and write it in a cell in Excel like this:
Hi Fred (Column A, Row 1)
Hi Alex (Column A, Row 2)
Actually I do:
xlswrite('name.xls', [a,b]);
but the result is this:
Hi (Column A, Row 1) Fred (Column B, Row 1)
Hi (Column A, Row 2) Alex (Column B, Row 2)
Thanks in advance for your help!

採用された回答

per isakson
per isakson 2014 年 11 月 5 日
編集済み: per isakson 2014 年 11 月 5 日
[a,b] &nbsp creates a &nbsp<2x2 cell>. That's why you get 2x2 "cells" in Excel. &nbsp Instead try
cac = cellfun( @(s1,s2) sprintf('%s %s',s1,s2), a, b, 'uni', false );
xlswrite('name.xls', cac );
  1 件のコメント
andrea
andrea 2014 年 11 月 5 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by