Prev: PN sequence generator
Next: Macro problem
From: joseph Frank on 10 Apr 2010 16:43 Hi , I have a cell array of 2 rows and 6 columns I want to combine the data of the rows to produce a 1 by 6 cell array. is their any function to merge the data. Regards J
From: Image Analyst on 10 Apr 2010 17:14 "joseph Frank" I would doubt it for the general case, only for special cases. A cell is like a bucket. You can put anything in the bucket that you want: strings, structures, vectors, multidimensional arrays, etc. If you have an array of buckets (say 2 buckets by 6 buckets on your floor), and 2 of the buckets in a given row (that you want to combine) have strings, and 2 of them have 1D arrays, and the other 3 contain 3D arrays, then how do you plan on combining them? It can only be done for the same data type. In that special case (which may be your case) you can combine them. It's discussed in the help under "Concatenating cell arrays": From the help: Here is an example. First, create three 3-row cell arrays of different widths: C1 = {'Aug' 'Sep'; '10' '17'; uint16(2004) uint16(2004)}; C2 = {'Dec' 'Jan' 'Feb'; '31' '2' '10'; ... uint16(2007) uint16(2008) uint16(2008)}; C3 = {'Jun'; '23'; uint16(2002)}; This creates arrays C1, C2, and C3: C1 C2 C3 'Aug' 'Sep' 'Dec' 'Jan' 'Feb' 'Jun' '10' '17' '31' '2' '10' '23' [2004] [2004] [2007] [2008] [2008] [2002] Use the curly brace operator to concatenate entire cell arrays, thus building a 1-by-3 cell array from the three initial arrays. Each cell of this new array holds its own cell array: C4 = {C1 C2 C3} C4 = {3x2 cell} {3x3 cell} {3x1 cell} Now use the square bracket operator on the same combination of cell arrays. This time MATLAB concatenates the contents of the cells together and produces a 3-by-6 cell array: C5 = [C1 C2 C3] C5 = 'Aug' 'Sep' 'Dec' 'Jan' 'Feb' 'Jun' '10' '17' '31' '2' '10' '23' [2004] [2004] [2007] [2008] [2008] [2002] Note The notation {} denotes the empty cell array, just as [] denotes the empty matrix for numeric arrays. You can use the empty cell array in any cell array assignments.
From: joseph Frank on 10 Apr 2010 17:33 great . it works. Thanks a lot
|
Pages: 1 Prev: PN sequence generator Next: Macro problem |