Cell to array of strings

조회 수: 143 (최근 30일)
Liam Ryan
Liam Ryan 2019년 10월 17일
답변: Robert U 2019년 10월 17일
Hi, say we have a 1 by 10 cell array of strings like the following:
{'C'} {'B'} {'A'} {'C2'} {'6'} {'Bob'} {'O'} {'A'} {'Camel'} {'Banana'}
How can one covert this to an array that is a 1 by 10 array? So in that array there would be 10 elements. I tried cell2mat command, but it just puts everything in a single element, but I want each of the cell to be a seperate element, not a single element. Thanks!

답변 (1개)

Robert U
Robert U 2019년 10월 17일
Hi Liam Ryan,
what you describe is not a cell array of strings but char. You can convert it straightforward by applying string().
TESTIN = {{'C'},{'B'},{'A'},{'C2'},{'6'},{'Bob'},{'O'},{'A'},{'Camel'},{'Banana'}};
TESTOUT = string(TESTIN);
Kind regards,
Robert

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by