Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab arrays with numbers and characters

  1. Nov 10, 2009 #1
    So, I'm trying to create an array with both numbers and specific characters, like # and C. I want it to be displayed like a standard array of numbers. So the output would resemble.

    7 7 7 7 7 7 7
    6 6 6 6 6 6 6
    5 # C 6 6 @ 6

    Thanks,
     
  2. jcsd
  3. Nov 10, 2009 #2
    You can't store different data types in the same matrix in Matlab in the manner in which you want. You can, however, use a cell array to do what you want. For instance, to create a 2x2 cell array with a mixture of double and chars one would type

    Code (Text):

    > C = {1 'a'; 'b' 21}

    C =

        [1]    'a'
        'b'    [21]
    Check Matlab's documentation for *loads* of info on how to use cell arrays.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab arrays with numbers and characters
  1. Matlab and arrays (Replies: 0)

  2. Arrays in MATLAB (Replies: 3)

Loading...