Merging cell arrays with variable number of elements
Mostrar comentarios más antiguos
I have a cell array x that can be of two forms depending on some condition cond
if cond x = {A B1 B2 C} else x = {A B1 B2 B3 C} end
where A, B1, B2, B3, and C are all row vectors. I want to define a variable B that gets set based on cond, and then have a single expression for x:
if cond B = {B1 B2} else B = {B1 B2 B3} end x= {A B C}
The above does not work because it will treat B as a cell array, not a group of vectors. For instance, with cond = 0, we get something like the following type for x
[1x2 double] {1x3 cell} [1x2 double]
How could I make the result to look like
[1x2 double] [1x3 double] [1x5 double] [1x2 double] [1x2 double]
Thanks Farzad
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!