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개)

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 CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by