How to convert 2*1 cell array into 1*2char array
13 ビュー (過去 30 日間)
表示 古いコメント
raghavendra kandukuri
2018 年 10 月 22 日
コメント済み: raghavendra kandukuri
2018 年 10 月 23 日
egr = Tier' % egr returns 'T2' 'S2' as 1*2 CELL
sgr = char(egr); % sgr returns T2
S2 as 2*2 char
My desired output should look like 'T2' 'S2' or 'T2','S2' in char
1 件のコメント
Guillaume
2018 年 10 月 22 日
Note that the only way a 2x1 cell array can be converted into a 1x2 char array is if each cell of the array contain a single character, or one cell contains 2 characters and the other none.
採用された回答
Walter Roberson
2018 年 10 月 23 日
egr = {'T2' 'S2'};
sgr = ['''', strjoin(egr, ''' '''), ''''];
disp(sgr)
This will display as
'T2' 'S2'
which is to say that sgr will be a character vector that contains those literal characters, which appears to be what you are asking for.
However, this appears to have nothing to do with your switch statement, since you have
switch (T3)
and T3 has nothing to do with egr or sgr.
その他の回答 (1 件)
madhan ravi
2018 年 10 月 22 日
編集済み: madhan ravi
2018 年 10 月 22 日
Tier={'T2';'S2'}'
egr=Tier
c=char(egr)
参考
カテゴリ
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!