Matlab arrays with numbers and characters

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 9K views
kaos4
Messages
4
Reaction score
0
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,
 
Physics news on Phys.org
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:
> C = {1 'a'; 'b' 21}

C = 

    [1]    'a' 
    'b'    [21]

Check Matlab's documentation for *loads* of info on how to use cell arrays.