How to make string from matrix?

2 ビュー (過去 30 日間)
Lolipop
Lolipop 2014 年 12 月 19 日
コメント済み: Lolipop 2014 年 12 月 19 日
Hello everyone.. Can anoyne help me with this.. I have matrix with dimension 662x2 for example
y=[111 20;123 43;117 89;....] on so on
and form that matrix I need to make string but in every new row to put '#' so matrix y should be converted in string like this
yy='111 20#123 43#117 89#..' and so on
Thank you!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 19 日
A=magic(4)
B=[num2cell(A');repmat({'#'},1,size(A,1))]
out=strjoin(cellfun(@num2str,B(:)','un',0))
  1 件のコメント
Lolipop
Lolipop 2014 年 12 月 19 日
Thank you

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

その他の回答 (1 件)

Star Strider
Star Strider 2014 年 12 月 19 日
This works:
yy = sprintf('%d %d#', y');
  1 件のコメント
Lolipop
Lolipop 2014 年 12 月 19 日
Thank you this works as well

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

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by