Can we have a mixed-type matrix in Matlab...and how? -
i'm trying write function matrix (specifically matrix) output, rows of show double-type variable , binary 'status'. no real reason , out of curiosity, wonder if there way have rows have different types.
many thanks
matlab offers 2 viable options storing mixed data types:
cell arrays
you can @ cell array special matrix , each element (called cell) can of different type (and size). instance:
c = {2, 'hello'} is cell array stores both double , string.
structures
structures can store values of different data types , sizes, each in different field. example, information in cell array above can represented structure in following way:
s.count = 2 s.name = 'hello'
recommendation:
seems struct looks more elegant needs; suppose you'll have field called status storing boolean value , field called number storing double. multiple values can store vector of booleans in status , vector of doubles in number. alternatively can have array of structs holding 1 boolean , 1 double each.
Comments
Post a Comment