连接两个字符串的单元格数组,并且它们之间有一个空格? [英] Concatenate two cell arrays of strings with a space in between?
本文介绍了连接两个字符串的单元格数组,并且它们之间有一个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何连接:
A = {'hello'; 'hi'; 'hey'}
与
B = {'Ben'; 'Karen'; 'Lisa'}
之间有一个空格以获取:
with a space in between to get:
C = {'hello Ben'; 'hi Karen'; 'hey Lisa'}
有没有一种快速的非循环方式?
Is there a fast non-looping way?
推荐答案
尽管执行循环,您仍可以使用strcat()
:
You can use strcat()
, although it performs a loop:
strcat(A,{' '}, B)
通过将空白封闭在一个单元格中来保留空白.
where the blank is preserved by enclosing it within a cell.
或者, FEX:CStrCatStr 是一种混合例程,可实现10倍的加速(取决于测试环境):
Alternatively, FEX:CStrCatStr is a mex routine which achieves a 10x speedup (depending on testing environment):
CStrCatStr(A,' ', B)
这篇关于连接两个字符串的单元格数组,并且它们之间有一个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文