Currently matlab coder is not supporting strcat
or strjoin
. Is there any anyway to circumvent this or custom function?
Edit: Input= [abcd] Expected output= 'a,b,c,d'
For strjoin
you might get away with sprintf
:
>> colorCell = [{'Red','Yellow'},{'Green','Blue'}];
>> colorList = strjoin(colorCell,',')
colorList =
Red,Yellow,Green,Blue
>> colorList = sprintf('%s,',colorCell{:}); colorList(end)=[]
colorList =
Red,Yellow,Green,Blue
If you can't use spintf
:
>> c = [colorCell(:) repmat({','},numel(colorCell),1)].';
>> colorList = [c{:}]; colorList(end)=[]
For strcat
, simple usage is often equivalent to using []
.
>> strcat(colorCell{:})
ans =
RedYellowGreenBlue
>> [colorCell{:}]
ans =
RedYellowGreenBlue
However, for more complex syntax, it's not that simple:
>> strcat({'Red','Yellow'},{'Green','Blue'})
ans =
'RedGreen' 'YellowBlue'
Do you need a solution for this usage? Perhaps the following:
colorCell1 = {'Red','Yellow'}; colorCell2 = {'Green','Blue'};
colorCell12 = [colorCell1;colorCell2];
c = mat2cell(colorCell12,size(colorCell12,1),ones(size(colorCell12,2),1));
cellfun(@(x)[x{:}],c,'uni',0)
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.