필터 지우기
필터 지우기

String problem

조회 수: 2 (최근 30일)
Raviteja
Raviteja 2011년 9월 10일
I want to store some strings in a row matrix. so used like this
>> str=['RR' 'DET' 'LMAX' 'ENT' 'LAM' 'TT'];
>> str
str =
RRDETLMAXENTLAMTT
It is stored as single string size of 1x17
Then I tried
>> str=['RR'; 'DET' ;'LMAX'; 'ENT'; 'LAM'; 'TT'];
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
I want to store each word in single cell of a row vector... How to do this?

답변 (1개)

Oleg Komarov
Oleg Komarov 2011년 9월 10일
Use a cell array:
cstr = {'RR' 'DET' 'LMAX' 'ENT' 'LAM' 'TT'};
to access it:
cstr{1}
  댓글 수: 3
Andrei Bobrov
Andrei Bobrov 2011년 9월 10일
X = [cstr;num2cell(Y)]
Oleg Komarov
Oleg Komarov 2011년 9월 10일
In general char class and numeric class cannot be "merged" but you can use the a cell array or you can canvert the numeric type to char (see num2str)

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

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by