Merging cell arrays with variable number of elements
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!