Filter löschen
Filter löschen

String problem

3 Ansichten (letzte 30 Tage)
Raviteja
Raviteja am 10 Sep. 2011
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?

Antworten (1)

Oleg Komarov
Oleg Komarov am 10 Sep. 2011
Use a cell array:
cstr = {'RR' 'DET' 'LMAX' 'ENT' 'LAM' 'TT'};
to access it:
cstr{1}
  3 Kommentare
Andrei Bobrov
Andrei Bobrov am 10 Sep. 2011
X = [cstr;num2cell(Y)]
Oleg Komarov
Oleg Komarov am 10 Sep. 2011
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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Chemistry finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by