I am trying to concatenate strings in a cell array using repmat in matlab.
What I want to do is something like:
aa={'xx','yy',repmat({'zz'},1,3)}
with the result equivalent to:
aa={'xx','yy','zz','zz','zz'}
but instead the result is:
{'xx','yy', {1x3 cell array} }
I realize that if I had a variable such as C=repmat('zz',1,3)
then I could do
aa{'xx','yy',C{:}}
but the problem is I don't want to define any other variables like C. I want to do this in line if possible. Any ideas?
use vector concatenation:
aa=[{'xx','yy'},repmat({'zz'},1,3)]
aa =
1×5 cell array
'xx' 'yy' 'zz' 'zz' 'zz'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.