필터 지우기
필터 지우기

cell array to char array?

조회 수: 431 (최근 30일)
raktim banerjee
raktim banerjee 2011년 1월 26일
댓글: Hary 2023년 3월 31일
Hello Sir!
How to convert a cell array to char array? I want to read 2 strings from a .txt file and want them in char type. if I do as follow those are cell type. The file contains 2 strings in 1st line, separated by a single space.
[a,b] = textread('inp.txt','%s%s',1)

채택된 답변

Walter Roberson
Walter Roberson 2011년 1월 26일
char(a) and char(b)
  댓글 수: 4
raktim banerjee
raktim banerjee 2011년 1월 26일
Tank you sir!
Hary
Hary 2023년 3월 31일
alternatively,
>> a = {'9a','abc'}
a =
1×2 cell array
{'9a'} {'abc'}
>> a{1}
ans =
'9a'

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

추가 답변 (1개)

piyari sadia
piyari sadia 2011년 8월 17일
letters_lut ='AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890'; HOW (letters_lut) is used to convert the cell array to a character?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 8월 17일
Please expand on your question. Conversion from cell array to character string is a matter of de-referencing each of the cell array entries to get the already-contained character string, and building up rows of a char array, with the rows padded (with blanks) to the length of the longest string. There is no look-up table involved in the process.

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

카테고리

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