How can I convert the name object to be a char instead of a cell?
Thank you very much.
Emily

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2022년 11월 3일

0 개 추천

a={'abc'}
a = 1×1 cell array
{'abc'}
whos a
Name Size Bytes Class Attributes a 1x1 110 cell
b=char(a)
b = 'abc'
whos b
Name Size Bytes Class Attributes b 1x3 6 char

댓글 수: 4

Emily Doherty
Emily Doherty 2022년 11월 3일
But then how do I replace the name 1x1 cell with the new 'b' value ?
Joseph Mah
Joseph Mah 2022년 11월 3일
You could just set a=char(a) if your goal is to make a char instead of a cell array, though will not work if you have multiple cells in your cell array. In that case maybe look into string arrays.
Emily Doherty
Emily Doherty 2022년 11월 3일
My cell array is only one cell. I get this error when I try to follow that logic
>> SubjStats(1, 1).basis.stim.values{1, 1}.name = char(SubjStats(1, 1).basis.stim.values{1, 1}.name)
Error using strcmp
Too many input arguments.Error in Dictionary/subsasgn (line 233)
if strcmp(s.type,'()')
Might it be that this field 'name' in that nested structure requires a cell of string?
try
SubjStats(1, 1).basis.stim.values{1, 1}.name='abc'

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

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 11월 3일

댓글:

2022년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by