cell array manipulation with string

1 回表示 (過去 30 日間)
Rick
Rick 2014 年 7 月 24 日
編集済み: Rick 2014 年 7 月 24 日
Write a line of MATLAB code that uses the cell array A to generate the string 'Cal Golden Bears'
A = {'Cal', 'Golden', 'Bears', [5 7], {[1 2 3 4]}}
A =
'Cal' 'Golden' 'Bears' [1x2 double] {1x1 cell}
The closest I've gotten so far is this, but I still don't have all three words in one string.
A(1:3)
ans =
'Cal' 'Golden' 'Bears'

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 24 日
編集済み: Azzi Abdelmalek 2014 年 7 月 24 日
[A{1:3}]
%or
strjoin(A(1:3))
  1 件のコメント
Rick
Rick 2014 年 7 月 24 日
編集済み: Rick 2014 年 7 月 24 日
[A{1:3}]
ans =
CalGoldenBears
strjoin(A(1:3))
ans =
Cal Golden Bears
both of these are not 'Cal Golden Bears', should have the ''

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by