1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Cell Array manipulation (matlab)

  1. Jul 22, 2014 #1

    Maylis

    User Avatar
    Gold Member

    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. jcsd
  3. Jul 23, 2014 #2

    jedishrfu

    Staff: Mentor

  4. Jul 23, 2014 #3

    Maylis

    User Avatar
    Gold Member

    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 ' '
     
  5. Jul 23, 2014 #4

    jedishrfu

    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 "\'"
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Cell Array manipulation (matlab)
Loading...