cell array manipulation with string

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일

0 개 추천

[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 ''

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2014년 7월 24일

편집:

2014년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by