필터 지우기
필터 지우기

How to merge str array with double array?

조회 수: 1 (최근 30일)
Julien Pezet
Julien Pezet 2019년 2월 27일
댓글: Julien Pezet 2019년 2월 27일
Hello all,
I have a cell array A and a double array B like the following:
A = {'21/02'
'22/02'
'25/02'}
B = [2 7 9
5 7 0
3 6 1]
I would like to merge them in order to obtain C like:
C = {'21/02' '2' '7' '9'
'22/02' '5' '7' '0'
'25/02' '3' '6' '1'}
But I'm stuck. I would appreciate any help!

채택된 답변

Jan
Jan 2019년 2월 27일
편집: Jan 2019년 2월 27일
A = {'21/02'; ...
'22/02'; ...
'25/02'}
B = [2 7 9; ...
5 7 0; ...
3 6 1]
C = [A, sprintfc('%d', B)]
  댓글 수: 1
Julien Pezet
Julien Pezet 2019년 2월 27일
Thanks Jan, perfect, it keeps NaN also!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

KSSV
KSSV 2019년 2월 27일
A = {'21/02'
'22/02'
'25/02'}
B = [2 7 9
5 7 0
3 6 1]
iwant = strcat(A,{' '},num2str(B))
  댓글 수: 1
Julien Pezet
Julien Pezet 2019년 2월 27일
Thanks for your reply,
I gives me:
iwant = {'21/02 2 7 9'
'22/02 5 7 0'
'25/02 3 6 1'}
instead of:
iwant = {'21/02' '2' '7' '9'
'22/02' '5' '7' '0'
'25/02' '3' '6' '1'}

댓글을 달려면 로그인하십시오.


madhan ravi
madhan ravi 2019년 2월 27일
C=cellstr([string(A),""+B])
  댓글 수: 1
Julien Pezet
Julien Pezet 2019년 2월 27일
Thanks Madhan! I did not mention that my B contains Nan, and your answer deletes them.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by