# Homework Help: Cell Array manipulation (matlab)

1. Jul 22, 2014

### Maylis

1. The problem statement, all variables and given/known data
Write a line of MATLAB code that uses the cell array A to generate the string 'Cal Golden Bears'

2. Relevant equations

3. The attempt at a solution
Code (Text):
A = {'Cal', 'Golden', 'Bears', [5 7], {[1 2 3 4]}}

A =

'Cal'    'Golden'    'Bears'    [1x2 double]    {1x1 cell}
The furthest I've gotten so far is A(1:3)
Code (Text):
A(1:3)

ans =

'Cal'    'Golden'    'Bears'
But I don't know how to concatenate them so that they are all one string. I think I am just supposed to use one command that can create the string.

2. Jul 23, 2014

### Staff: Mentor

3. Jul 23, 2014

### Maylis

I never heard of that command before. Is there anyway by manipulating the cell array sort of how I did with A(1:3)?

Code (Text):
strjoin(A(1:3))

ans =

Cal Golden Bears
Still misses the ' '

4. Jul 23, 2014

### Staff: Mentor

cant you then say x = "'" + strjoin(...) + "'" ?

note: I quoted the single quote not sure if you'll need to backslash it too? ie "\'"