Concatenating a double array and two cell arrays

Hi there,
I'm trying to add to arrays (a & b) to my data set, which should be very simple, but I keep running into problems.
The working pieces:
>> whos a
Name Size Bytes Class Attributes
a 759x1 89562 cell
>> whos b
Name Size Bytes Class Attributes
b 759x1 94116 cell
>> whos site_Cflux
Name Size Bytes Class Attributes
site_Cflux 759x3 18216 double
Example of my code:
sitedata=horzcat(a, b, site_Cflux)
Which should work (they all have the same number of rows), but I get this message:
Error using horzcat Dimensions of matrices being concatenated are not consistent.
Any ideas? Is this a cell array/double array issue? I thought they were compatible.
Thanks a million.

 Respuesta aceptada

Leah
Leah el 5 de Jun. de 2013
does this work
sitedata=horzcat(a, b, num2cell(site_Cflux))

5 comentarios

Kate
Kate el 5 de Jun. de 2013
Perfect, thanks a bunch
Leah
Leah el 5 de Jun. de 2013
No problem, please accept my answer
Kate
Kate el 6 de Jun. de 2013
Absolutely! One quick question, do you think that there is a way to do this without turning my number matrix into a cell matrix? I can't run some of my functions on the data now (example: rem).
Nope. If you want to have the entries from site_Cflux be placed against the corresponding row entries of "a" and "b", then you need to break up the numeric array to become cell entries.
You can extract from the cell and convert back to numeric arrays if you need to.
And naturally if "a" and "b" contain numeric values, some number of entries for each row, then you could convert the whole thing to a single numeric array:
horzcat(cell2mat(a), cell2mat(b), site_Cflux)
Kate
Kate el 6 de Jun. de 2013
I end up getting error messages like this:
Undefined function 'rem' for input arguments of type 'cell'.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Etiquetas

Preguntada:

el 5 de Jun. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by